lua/wrappers/game/lua_character.cpp
/**
     * Sets the AI function, the function takes 2 parameters, the
     * character currently being processed and the current delta time.
     * The function can be set to nil for default behaviour.
     *
     * @param function func The new AI function.
     * @returns am.character This
     */
Sets the AI function, the function takes 2 parameters, the
character currently being processed and the current delta time.
The function can be set to nil for default behaviour.

@param function func The new AI function.
Sets the AI function the function takes 2 parameters the character currently being processed and the current delta time . The function can be set to nil for default behaviour . @param function func The new AI function .
int Character_ai_func(lua_State *lua)
	{
		Character *obj = castUData<Character>(lua, 1);
		if (obj)
		{
            if (lua_gettop(lua) == 1)
            {
                int funcRef = obj->getAIFunc();
                if (funcRef == LUA_REFNIL)
                {
                    lua_pushnil(lua);
                    return 1;
                }
                lua_rawgeti(lua, LUA_REGISTRYINDEX, funcRef);
                return 1;
            }
            else
            {
                if (lua_isnil(lua, 2))
                {
                    obj->setAIFunc(LUA_REFNIL);
                    lua_first(lua);
                }
    			if (lua_isfunction(lua, -1))
	    		{
		    		int funcRef = luaL_ref(lua, LUA_REGISTRYINDEX);
			    	obj->setAIFunc(funcRef);
    				lua_first(lua);
	    		}
            }
			return LuaState::expectedArgs(lua, "ai_func", 2, "function function, nil function");
		}
		return LuaState::expectedContext(lua, "ai_func", "am.character");
	}
int Character_ai_func ( lua_State * lua ) { Character * obj = castUData < Character > ( lua , 1 ) ; if ( obj ) { if ( lua_gettop ( lua ) == 1 ) { int funcRef = obj -> getAIFunc ( ) ; if ( funcRef == LUA_REFNIL ) { lua_pushnil ( lua ) ; return 1 ; } lua_rawgeti ( lua , LUA_REGISTRYINDEX , funcRef ) ; return 1 ; } else { if ( lua_isnil ( lua , 2 ) ) { obj -> setAIFunc ( LUA_REFNIL ) ; lua_first ( lua ) ; } if ( lua_isfunction ( lua , -1 ) ) { int funcRef = luaL_ref ( lua , LUA_REGISTRYINDEX ) ; obj -> setAIFunc ( funcRef ) ; lua_first ( lua ) ; } } return LuaState :: expectedArgs ( lua , " " , 2 , " " ) ; } return LuaState :: expectedContext ( lua , " " , " " ) ; }
Sets the AI function, the function takes 2 parameters, the
 character currently being processed and the current delta time.
Sets the AI function the function takes 2 parameters the character currently being processed and the current delta time .