changed old manifest.toml to Packet.lua and some improvements for future 100% Packet.lua implementation

This commit is contained in:
2025-10-25 12:44:40 -03:00
parent 5ba30c617a
commit ecce74d2e9
11 changed files with 420 additions and 130 deletions

View File

@@ -0,0 +1,55 @@
package packet
import lua "github.com/yuin/gopher-lua"
func getStringFromTable(table *lua.LTable, key string) string {
value := table.RawGetString(key)
if value.Type() == lua.LTString {
return value.String()
}
return ""
}
func getStringArrayFromTable(L *lua.LState, table *lua.LTable, key string) []string {
value := table.RawGetString(key)
if value.Type() != lua.LTTable {
return []string{}
}
arrayTable := value.(*lua.LTable)
var result []string
arrayTable.ForEach(func(_, value lua.LValue) {
if value.Type() == lua.LTString {
result = append(result, value.String())
}
})
return result
}
func getFunctionFromTable(table *lua.LTable, key string) *lua.LFunction {
value := table.RawGetString(key)
if value.Type() == lua.LTFunction {
return value.(*lua.LFunction)
}
return nil
}
func getDependenciesFromTable(L *lua.LState, table *lua.LTable, key string) map[string]string {
value := table.RawGetString(key)
if value.Type() != lua.LTTable {
return map[string]string{}
}
depsTable := value.(*lua.LTable)
dependencies := make(map[string]string)
depsTable.ForEach(func(key, value lua.LValue) {
if key.Type() == lua.LTString && value.Type() == lua.LTString {
dependencies[key.String()] = value.String()
}
})
return dependencies
}