Beispiel #1
0
// Ripped from game/ai/ai.go - should probably sync up with it
func registerUtilityFunctions(L *lua.State) {
	L.Register("print", func(L *lua.State) int {
		var res string
		n := L.GetTop()
		for i := -n; i < 0; i++ {
			res += LuaStringifyParam(L, i) + " "
		}
		base.Log().Printf("GameScript(%p): %s", L, res)
		return 0
	})
}
Beispiel #2
0
Datei: lua.go Projekt: vron/fm
func register(l *lua.State) {
	for k, v := range funcs {
		// k is ideftifier string and v is the function to call

		// First we check the function
		t := reflect.TypeOf(v)
		if t.Kind() != reflect.Func {
			log.Println("Invalid function: ", k)
			continue
		}

		f, e := createwrap(reflect.ValueOf(v))

		if e != nil {
			log.Println("Error creating wrapper '", k, "': ", e)
			continue
		}

		l.Register(k, f)
	}
}