package minecraft import ( "github.com/ppacher/nbt" lua "github.com/yuin/gopher-lua" ) func TagToLuaValue(L *lua.LState, tag nbt.Tag) lua.LValue { switch tag.TagID() { case nbt.TagDouble: return lua.LNumber(tag.(*nbt.DoubleTag).Value) case nbt.TagFloat: return lua.LNumber(tag.(*nbt.FloatTag).Value) case nbt.TagInt: return lua.LNumber(tag.(*nbt.IntTag).Value) case nbt.TagLong: return lua.LNumber(tag.(*nbt.LongTag).Value) case nbt.TagString: return lua.LString(tag.(*nbt.StringTag).Value) case nbt.TagCompound: t := L.NewTable() c := tag.(*nbt.CompoundTag) for key, v := range c.Tags { t.RawSetString(key, TagToLuaValue(L, v)) } return t } return lua.LNil }