本文整理汇总了Golang中github.com/xenith-studios/golua.State.IsNil方法的典型用法代码示例。如果您正苦于以下问题:Golang State.IsNil方法的具体用法?Golang State.IsNil怎么用?Golang State.IsNil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/xenith-studios/golua.State
的用法示例。
在下文中一共展示了State.IsNil方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Push
func (exec aoeExec) Push(L *lua.State, g *game.Game) {
exec.BasicActionExec.Push(L, g)
if L.IsNil(-1) {
return
}
L.PushString("Pos")
game.LuaPushPoint(L, exec.X, exec.Y)
L.SetTable(-3)
}
示例2: Push
func (exec summonExec) Push(L *lua.State, g *game.Game) {
exec.BasicActionExec.Push(L, g)
if L.IsNil(-1) {
return
}
_, x, y := g.FromVertex(exec.Pos)
L.PushString("Pos")
game.LuaPushPoint(L, x, y)
L.SetTable(-3)
}
示例3: LuaIsEntity
func LuaIsEntity(L *lua.State, index int) bool {
L.PushString("type")
L.GetTable(index - 1)
if L.IsNil(-1) {
L.Pop(1)
return false
}
if L.ToString(-1) == "Entity" {
L.Pop(1)
return true
}
L.Pop(1)
return false
}
示例4: Push
func (exec *moveExec) Push(L *lua.State, g *game.Game) {
exec.BasicActionExec.Push(L, g)
if L.IsNil(-1) {
return
}
L.PushString("Path")
L.NewTable()
for i := range exec.Path {
L.PushInteger(i + 1)
_, x, y := g.FromVertex(exec.Path[i])
game.LuaPushPoint(L, x, y)
L.SetTable(-3)
}
L.SetTable(-3)
}
示例5: Push
func (exec interactExec) Push(L *lua.State, g *game.Game) {
exec.BasicActionExec.Push(L, g)
if L.IsNil(-1) {
return
}
L.PushString("Toggle Door")
L.PushBoolean(exec.Toggle_door)
L.SetTable(-3)
if exec.Toggle_door {
L.PushString("Door")
game.LuaPushDoor(L, g, exec.getDoor(g))
} else {
L.PushString("Target")
game.LuaPushEntity(L, g.EntityById(exec.Target))
}
L.SetTable(-3)
}
示例6: LuaEncodeValue
// Encodes a lua value, only bool, number, nil, table, and string can be
// encoded. If an unencodable value is encountered an error will be
// returned.
func LuaEncodeValue(w io.Writer, L *lua.State, index int) error {
var err1, err2, err3 error
switch {
case L.IsBoolean(index):
err1 = binary.Write(w, binary.LittleEndian, luaEncBool)
var v byte = 0
if L.ToBoolean(index) {
v = 1
}
err2 = binary.Write(w, binary.LittleEndian, v)
case L.IsNumber(index):
err1 = binary.Write(w, binary.LittleEndian, luaEncNumber)
err2 = binary.Write(w, binary.LittleEndian, L.ToNumber(index))
case L.IsNil(index):
err1 = binary.Write(w, binary.LittleEndian, luaEncNil)
case LuaIsEntity(L, index):
err1 = binary.Write(w, binary.LittleEndian, luaEncEntity)
L.PushString("id")
L.GetTable(index - 1)
err2 = binary.Write(w, binary.LittleEndian, uint64(L.ToInteger(-1)))
L.Pop(1)
case L.IsTable(index):
err1 = binary.Write(w, binary.LittleEndian, luaEncTable)
err2 = LuaEncodeTable(w, L, index)
case L.IsString(index):
err1 = binary.Write(w, binary.LittleEndian, luaEncString)
str := L.ToString(index)
err2 = binary.Write(w, binary.LittleEndian, uint32(len(str)))
err3 = binary.Write(w, binary.LittleEndian, []byte(str))
default:
return errors.New(fmt.Sprintf("Cannot encode lua type id == %d.", L.Type(index)))
}
switch {
case err1 != nil:
return err1
case err2 != nil:
return err2
case err3 != nil:
return err3
}
return nil
}