Compare commits

..

4 commits
v0.1.0 ... main

Author SHA1 Message Date
7f1fc0890f Typo 2025-05-09 07:30:03 +02:00
3ae999c98b Added JSON response of LUA variable 2025-05-09 07:28:12 +02:00
28a2d54089 Removed unnecessary function parameter 2025-05-08 14:47:13 +02:00
feed1d5d43 Renamed package 2025-05-08 14:30:04 +02:00
2 changed files with 9 additions and 3 deletions

2
go.mod
View file

@ -1,4 +1,4 @@
module lua
module git.gibonuddevalla.se/go/lua
go 1.24.2

10
pkg.go
View file

@ -19,12 +19,12 @@ func NewLUA() (lua LUA) {
return
}
func (l *LUA) SetStructInLUA(L *gopherLua.LState, varname string, strct any) (ltable gopherLua.LValue, err error) {
func (l *LUA) SetStructInLUA(varname string, strct any) (ltable gopherLua.LValue, err error) {
// JSON is used as a communications layer.
j, _ := json.Marshal(strct)
// JSON is decoded to a Lua table.
ltable, err = luaJSON.Decode(L, j)
ltable, err = luaJSON.Decode(l.state, j)
if err != nil {
return
}
@ -38,6 +38,12 @@ func (l *LUA) GetStructFromLUA(ltable gopherLua.LValue, strct any) (err error) {
return
}
func (l *LUA) GetJSONFromLUA(ltable gopherLua.LValue) (j []byte) {
j, _ = luaJSON.Encode(ltable)
return
}
func (l *LUA) Run(script string) (err error) {
return l.state.DoString(script)
}