/** * @brief Sets a jump's known state. * * @usage j:setKnown( false ) -- Makes jump unknown. * @luaparam j Jump to set known. * @luaparam b Whether or not to set as known (defaults to true). * @luafunc setKnown( j, b ) */ static int jumpL_setKnown( lua_State *L ) { int b, offset, changed; JumpPoint *jp; jp = luaL_validjumpSystem(L, 1, &offset, NULL); /* True if boolean isn't supplied. */ if (lua_gettop(L) > offset) b = lua_toboolean(L, 1 + offset); else b = 1; changed = (b != (int)jp_isKnown(jp)); if (b) jp_setFlag( jp, JP_KNOWN ); else jp_rmFlag( jp, JP_KNOWN ); /* Update outfits image array. */ if (changed) outfits_updateEquipmentOutfits(); return 0; }
/** * @brief Gets the system that a jump point exists in. * * @usage s = j:system() * @luaparam j Jump to get the system of. * @luareturn The jump's system. * @luafunc system( j ) */ static int jumpL_system( lua_State *L ) { StarSystem *sys; luaL_validjumpSystem(L, 1, NULL, &sys); lua_pushsystem(L,sys->id); return 1; }
/** * @brief Gets the system that a jump point exists in. * * @usage s = j:system() * @luaparam j Jump to get the system of. * @luareturn The jump's system. * @luafunc system( j ) */ static int jumpL_system( lua_State *L ) { StarSystem *sys; LuaSystem ls; luaL_validjumpSystem(L, 1, NULL, &sys); ls.id = sys->id; lua_pushsystem(L,ls); return 1; }
/** * @brief Sets a jump's known state. * * @usage j:setKnown( false ) -- Makes jump unknown. * @luaparam j Jump to set known. * @luaparam b Whether or not to set as known (defaults to true). * @luafunc setKnown( j, b ) */ static int jumpL_setKnown( lua_State *L ) { int b, offset; JumpPoint *jp; jp = luaL_validjumpSystem(L, 1, &offset, NULL); /* True is boolean isn't supplied. */ if (lua_gettop(L) > offset ) b = lua_toboolean(L, 1 + offset); else b = 1; if (b) jp_setFlag( jp, JP_KNOWN ); else jp_rmFlag( jp, JP_KNOWN ); return 0; }
/** * @brief Gets a jump directly. * * @param L Lua state to get jump from. * @param ind Index to check. * @param[out] sys System the jump exists in. * @return Jump found at the index in the state. */ JumpPoint* luaL_validjump( lua_State *L, int ind ) { return luaL_validjumpSystem(L, ind, NULL, NULL); }