示例#1
0
文件: basic.go 项目: syntropy/golua
func main() {
	var L *golua.State

	L = golua.NewState()
	L.OpenLibs()

	L.GetField(golua.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)

	L.Close()
}
示例#2
0
文件: panic.go 项目: syntropy/golua
func main() {

	var L *lua.State

	L = lua.NewState()
	defer L.Close()
	L.OpenLibs()

	currentPanicf := L.AtPanic(nil)
	currentPanicf = L.AtPanic(currentPanicf)
	newPanic := func(L1 *lua.State) int {
		fmt.Println("I AM PANICKING!!!")
		return currentPanicf(L1)
	}

	L.AtPanic(newPanic)

	//force a panic
	L.PushNil()
	L.Call(0, 0)
}