4 "github.com/anon55555/mt"
5 "github.com/yuin/gopher-lua"
8 //go:generate ./read_mkauto.lua
10 func readBool(l *lua.LState, val lua.LValue, ptr *bool) {
11 if val.Type() != lua.LTBool {
12 panic("invalid value for bool: must be a boolean")
14 *ptr = bool(val.(lua.LBool))
17 func readString(l *lua.LState, val lua.LValue, ptr *string) {
18 if val.Type() != lua.LTString {
19 panic("invalid value for string: must be a string")
21 *ptr = string(val.(lua.LString))
24 func readSliceByte(l *lua.LState, val lua.LValue, ptr *[]byte) {
25 if val.Type() != lua.LTString {
26 panic("invalid value for []byte: must be a string")
28 *ptr = []byte(val.(lua.LString))
31 func readSliceField(l *lua.LState, val lua.LValue, ptr *[]mt.Field) {
32 if val.Type() != lua.LTTable {
33 panic("invalid value for []Field: must be a table")
35 val.(*lua.LTable).ForEach(func(k, v lua.LValue) {
36 if k.Type() != lua.LTString || v.Type() != lua.LTString {
37 panic("invalid value for Field: key and value must be strings")
39 *ptr = append(*ptr, mt.Field{Name: string(k.(lua.LString)), Value: string(v.(lua.LString))})
43 func readPointedThing(l *lua.LState, val lua.LValue, ptr *mt.PointedThing) {
44 if val.Type() != lua.LTTable {
45 panic("invalid value for PointedThing: must be a table")
47 id := l.GetField(val, "id")
51 readAOID(l, id, &(*pt).ID)
54 pt := &mt.PointedNode{}
55 readVec3Int16(l, l.GetField(val, "under"), &(*pt).Under)
56 readVec3Int16(l, l.GetField(val, "above"), &(*pt).Above)