/** * @brief Returns the pos3 from the metatable at index. */ static pos3_t* lua_topos3 (lua_State *L, int index) { if (lua_ispos3(L, index)) { return (pos3_t*) lua_touserdata(L, index); } luaL_typerror(L, index, POS3_METATABLE); return NULL; }
/** * @brief Makes the actor face the position. */ static int pos3L_face (lua_State *L) { pos3_t *pos; assert(lua_ispos3(L, 1)); pos = lua_topos3(L, 1); AI_TurnIntoDirection(AIL_ent, *pos); lua_pushboolean(L, 1); return 1; }
/** * @brief Puts the pos3 information in a string. */ static int pos3L_tostring (lua_State *L) { pos3_t *p; char buf[MAX_VAR]; assert(lua_ispos3(L, 1)); p = lua_topos3(L, 1); Com_sprintf(buf, sizeof(buf), "Pos3( x=%d, y=%d, z=%d )", (*p)[0], (*p)[1], (*p)[2]); lua_pushstring(L, buf); return 1; }
/** * @brief Makes the actor head to the position. */ static int pos3L_goto (lua_State *L) { pos3_t *pos; assert(lua_ispos3(L, 1)); /* Calculate move table. */ G_MoveCalc(0, AIL_ent, AIL_ent->pos, G_ActorUsableTUs(AIL_ent)); gi.MoveStore(level.pathingMap); /* Move. */ pos = lua_topos3(L, 1); G_ClientMove(*AIL_player, 0, AIL_ent, *pos); lua_pushboolean(L, 1); return 1; }