本文整理汇总了Golang中github.com/xenith-studios/golua.State.SetMetaTable方法的典型用法代码示例。如果您正苦于以下问题:Golang State.SetMetaTable方法的具体用法?Golang State.SetMetaTable怎么用?Golang State.SetMetaTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/xenith-studios/golua.State
的用法示例。
在下文中一共展示了State.SetMetaTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: LuaPushEntity
//.........这里部分代码省略.........
L.SetTable(-3)
// Meta table for the Entity so that any dynamic data is generated
// on-the-fly
LuaPushSmartFunctionTable(L, FunctionTable{
"Conditions": func() {
L.NewTable()
for _, condition := range ent.Stats.ConditionNames() {
L.PushString(condition)
L.PushBoolean(true)
L.SetTable(-3)
}
},
"Side": func() {
L.NewTable()
sides := map[string]Side{
"Denizen": SideHaunt,
"Intruder": SideExplorers,
"Npc": SideNpc,
"Object": SideObject,
}
for str, side := range sides {
L.PushString(str)
L.PushBoolean(ent.Side() == side)
L.SetTable(-3)
}
},
"State": func() {
L.PushString(ent.Sprite().State())
},
"Master": func() {
L.NewTable()
for key, val := range ent.Ai_data {
L.PushString(key)
L.PushString(val)
L.SetTable(-3)
}
},
"GearOptions": func() {
L.NewTable()
if ent.ExplorerEnt != nil {
for _, gear_name := range ent.ExplorerEnt.Gear_names {
var g Gear
g.Defname = gear_name
base.GetObject("gear", &g)
L.PushString(gear_name)
L.PushString(g.Large_icon.Path.String())
L.SetTable(-3)
}
}
},
"Gear": func() {
if ent.ExplorerEnt != nil && ent.ExplorerEnt.Gear != nil {
L.PushString(ent.ExplorerEnt.Gear.Name)
} else {
L.PushNil()
}
},
"Actions": func() {
L.NewTable()
for _, action := range ent.Actions {
L.PushString(action.String())
action.Push(L)
L.SetTable(-3)
}
},
"Pos": func() {
x, y := ent.Pos()
LuaPushPoint(L, x, y)
},
"Corpus": func() {
L.PushInteger(ent.Stats.Corpus())
},
"Ego": func() {
L.PushInteger(ent.Stats.Ego())
},
"HpCur": func() {
L.PushInteger(ent.Stats.HpCur())
},
"HpMax": func() {
L.PushInteger(ent.Stats.HpMax())
},
"ApCur": func() {
L.PushInteger(ent.Stats.ApCur())
},
"ApMax": func() {
L.PushInteger(ent.Stats.ApMax())
},
"Info": func() {
L.NewTable()
L.PushString("LastEntityThatIAttacked")
LuaPushEntity(L, ent.Game().EntityById(ent.Info.LastEntThatIAttacked))
L.SetTable(-3)
L.PushString("LastEntThatAttackedMe")
LuaPushEntity(L, ent.Game().EntityById(ent.Info.LastEntThatAttackedMe))
L.SetTable(-3)
},
})
L.SetMetaTable(-2)
}