package main import ( "fmt" "github.com/vxcontrol/golua/lua" ) func test(L *lua.State) int { fmt.Println("hello world! from go!") return 0 } func test2(L *lua.State) int { arg := L.CheckInteger(-1) argfrombottom := L.CheckInteger(1) fmt.Print("test2 arg: ") fmt.Println(arg) fmt.Print("from bottom: ") fmt.Println(argfrombottom) return 0 } func main() { L := lua.NewState() defer L.Close() L.OpenLibs() L.GetField(lua.LUA_GLOBALSINDEX, "print") L.PushString("Hello World!") L.Call(1, 0) L.PushGoFunction(test) L.PushGoFunction(test) L.PushGoFunction(test) L.PushGoFunction(test) L.PushGoFunction(test2) L.PushInteger(42) L.Call(1, 0) L.Call(0, 0) L.Call(0, 0) L.Call(0, 0) // this will fail as we didn't register test2 function err := L.DoString("test2(42)") fmt.Printf("Ciao %v\n", err) }