本文整理匯總了Golang中github.com/aarzilli/golua/lua.State.GetMetaTable方法的典型用法代碼示例。如果您正苦於以下問題:Golang State.GetMetaTable方法的具體用法?Golang State.GetMetaTable怎麽用?Golang State.GetMetaTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aarzilli/golua/lua.State
的用法示例。
在下文中一共展示了State.GetMetaTable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MessThingIndex
func MessThingIndex(state *lua.State) int {
log.Println("HEY WE MADE IT")
printStackTypes(state)
state.GetMetaTable(1)
state.LGetMetaTable(ThingMetaTableName)
isThing := state.RawEqual(-1, -2)
state.Pop(2)
if !isThing {
log.Println("!!! OMG ARG #1 IS NOT A MESS.THING !!!")
}
fieldName := state.CheckString(2)
log.Println("Arg #2 checks out, it's a string")
thing := checkThing(state, 1)
log.Println("So we're tryin'a look up", fieldName, "on thing", thing.Id)
if member, ok := MessThingMembers[fieldName]; ok {
return member(state, thing)
}
// That wasn't one of our members, so look it up in our Table.
if data, ok := thing.Table[fieldName]; ok {
// TODO: instead of pushing a whole map if the script asks for one, maybe we should use another kind of userdata that tracks the name & can access its submembers until the script asks for the leaf (or a non-existent branch)?
pushValue(state, data)
return 1
}
// uh... I guess we didn't do anything, so...?
return 0
}
示例2: isValueProxy
func isValueProxy(L *lua.State, idx int) bool {
res := false
if L.IsUserdata(idx) {
L.GetMetaTable(idx)
if !L.IsNil(-1) {
L.GetField(-1, "luago.value")
res = !L.IsNil(-1)
L.Pop(1)
}
L.Pop(1)
}
return res
}