本文整理汇总了Golang中github.com/xenith-studios/golua.State.PushNumber方法的典型用法代码示例。如果您正苦于以下问题:Golang State.PushNumber方法的具体用法?Golang State.PushNumber怎么用?Golang State.PushNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/xenith-studios/golua.State
的用法示例。
在下文中一共展示了State.PushNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: LuaDecodeValue
// Decodes a value from the reader and pushes it onto the stack
func LuaDecodeValue(r io.Reader, L *lua.State, g *Game) error {
var le luaEncodable
err := binary.Read(r, binary.LittleEndian, &le)
if err != nil {
return err
}
switch le {
case luaEncBool:
var v byte
err = binary.Read(r, binary.LittleEndian, &v)
L.PushBoolean(v == 1)
case luaEncNumber:
var f float64
err = binary.Read(r, binary.LittleEndian, &f)
L.PushNumber(f)
case luaEncNil:
L.PushNil()
case luaEncEntity:
var id uint64
err = binary.Read(r, binary.LittleEndian, &id)
ent := g.EntityById(EntityId(id))
LuaPushEntity(L, ent)
if ent != nil {
base.Log().Printf("LUA: Push Ent %s", ent.Name)
} else {
base.Log().Printf("LUA: Push Ent NIL")
}
case luaEncTable:
err = LuaDecodeTable(r, L, g)
case luaEncString:
var length uint32
err = binary.Read(r, binary.LittleEndian, &length)
if err != nil {
return err
}
sb := make([]byte, length)
err = binary.Read(r, binary.LittleEndian, &sb)
L.PushString(string(sb))
default:
return errors.New(fmt.Sprintf("Unknown lua value id == %d.", le))
}
if err != nil {
return err
}
return nil
}