Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
2 changed files with 3 additions and 9 deletions
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
|||
module git.gibonuddevalla.se/go/lua
|
||||
module lua
|
||||
|
||||
go 1.24.2
|
||||
|
||||
|
|
10
pkg.go
10
pkg.go
|
@ -19,12 +19,12 @@ func NewLUA() (lua LUA) {
|
|||
return
|
||||
}
|
||||
|
||||
func (l *LUA) SetStructInLUA(varname string, strct any) (ltable gopherLua.LValue, err error) {
|
||||
func (l *LUA) SetStructInLUA(L *gopherLua.LState, 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.state, j)
|
||||
ltable, err = luaJSON.Decode(L, j)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -38,12 +38,6 @@ 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)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue