You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I call ls.NewClosure and set local variable
func Test() {
L := lua.NewState()
defer L.Close()
L.SetGlobal("i", lua.LNumber(11))
L.NewClosure(func (ls *lua.LState) int {
// what can i do at here
// maybe ls.Push ? but it's no name
// maybe ls.GetStack and ls.SetLocal, but I don't know how to set the local variable named i
ls.DoString("return i")
})
}
like lua code
i = 11
return (function()
local i = 10
return i
end)()
the return value is 10
The text was updated successfully, but these errors were encountered:
How can I call ls.NewClosure and set local variable
like lua code
the return value is 10
The text was updated successfully, but these errors were encountered: