19#include "nlua_player.h"
30#include "land_outfits.h"
33#include "map_overlay.h"
36#include "nlua_colour.h"
37#include "nlua_commodity.h"
38#include "nlua_outfit.h"
39#include "nlua_pilot.h"
42#include "nlua_system.h"
49#include "player_fleet.h"
50#include "player_inventory.h"
53#define PLAYER_CHECK() if (player.p == NULL) return 0
285 money =
CLAMP( CREDITS_MIN, CREDITS_MAX, (credits_t)round(luaL_checknumber(L,1)) );
287 if (lua_isstring(L,2)) {
289 reason = lua_tostring(L,2);
292 nohooks = lua_toboolean(L,2);
297 p[0].type = HOOK_PARAM_NUMBER;
298 p[0].u.num = (double)money;
299 if (reason != NULL) {
300 p[1].type = HOOK_PARAM_STRING;
304 p[1].type = HOOK_PARAM_NIL;
306 p[2].type = HOOK_PARAM_SENTINEL;
328 int decimals = luaL_optinteger(L,1,-1);
333 char buf[ ECON_CRED_STRLEN ];
335 lua_pushstring(L, buf);
359 int decimals = luaL_optinteger(L,1,-1);
365 wealth += po[i].q * po[i].o->price;
368 lua_pushnumber(L, wealth);
370 char buf[ ECON_CRED_STRLEN ];
371 credits2str( buf, wealth, decimals );
372 lua_pushstring(L, buf);
389 const char *str = luaL_checkstring(L,1);
390 int display = lua_toboolean(L,2);
443 str = luaL_checkstring(L,1);
444 duration = luaL_optnumber(L,2,10.);
445 fontsize = luaL_optinteger(L,3,OMSG_FONT_DEFAULT_SIZE);
446 col = luaL_optcolour(L,4,&cWhite);
449 if (duration < 1e-10)
453 id = omsg_add( str, duration, fontsize, col );
454 lua_pushnumber( L,
id );
477 id = luaL_checklong(L,1);
478 str = luaL_checkstring(L,2);
479 duration = luaL_checknumber(L,3);
482 if (duration < 1e-10)
486 ret = omsg_change(
id, str, duration );
487 lua_pushboolean(L,!ret);
500 unsigned int id = luaL_checklong(L,1);
515 if (lua_gettop(L)==0)
518 b = lua_toboolean(L, 1);
521 player_rmFlag(PLAYER_NOSAVE);
523 player_setFlag(PLAYER_NOSAVE);
600 if (lua_gettop(L) > 0) {
601 double f = luaL_checknumber(L,1);
623 lua_pushboolean( L, player_isFlag( PLAYER_AUTONAV ) );
643 dest = map_getDestination( &jumps );
649 lua_pushnumber( L, jumps );
665 const char *str = luaL_optstring(L,1,NULL);
680 double timer = luaL_optnumber(L,1,0.);
694 double speed = luaL_optnumber( L, 1, -1 );
728 const char *abort_msg;
738 b = lua_toboolean( L, 1 );
739 if (!lua_isnoneornil(L,2)) {
740 if (!lua_istable(L,2)) {
741 NLUA_ERROR( L, _(
"Second parameter to cinematics should be a table of options or omitted!") );
745 lua_getfield( L, 2,
"abort" );
746 if (!lua_isnil( L, -1 ))
747 abort_msg = luaL_checkstring( L, -1 );
750 lua_getfield( L, 2,
"gui" );
751 f_gui = lua_toboolean(L, -1);
754 lua_getfield( L, 2,
"no2x" );
755 f_2x = lua_toboolean(L, -1);
758 lua_getfield( L, 2,
"speed" );
759 speed = luaL_optnumber(L,-1,1.);
774 player_setFlag( PLAYER_CINEMATICS );
776 player_setFlag( PLAYER_CINEMATICS_GUI );
778 player_setFlag( PLAYER_CINEMATICS_2X );
788 player_rmFlag( PLAYER_CINEMATICS );
789 player_rmFlag( PLAYER_CINEMATICS_GUI );
790 player_rmFlag( PLAYER_CINEMATICS_2X );
807 double spfx_mod = luaL_checknumber(L,1);
849 lua_pushboolean( L,
landed );
864 NLUA_ERROR(L,_(
"Player must be landed to force takeoff."));
888 NLUA_ERROR(L,_(
"Spob '%s' is not in a system!"), spob->
name);
892 pilot_rmFlag(
player.
p, PILOT_HYPERSPACE );
893 pilot_rmFlag(
player.
p, PILOT_HYP_BEGIN );
894 pilot_rmFlag(
player.
p, PILOT_HYP_BRAKE );
895 pilot_rmFlag(
player.
p, PILOT_HYP_PREP );
912 lua_rawgeti(naevL, LUA_REGISTRYINDEX, spob->
lua_land);
915 if (nlua_pcall( spob->
lua_env, 2, 0 )) {
916 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), spob->
name,
"land", lua_tostring(naevL,-1));
945 const char *str = NULL;
947 if (lua_gettop(L) > 0) {
948 b = lua_toboolean(L,1);
949 if (lua_isstring(L,2))
950 str = lua_tostring(L,2);
956 player_rmFlag( PLAYER_NOLAND );
958 player_setFlag( PLAYER_NOLAND );
988 NLUA_ERROR(L, _(
"Must be landed to set the active land window."));
992 str = luaL_checkstring(L,1);
993 if (strcasecmp(str,
"main")==0)
994 win = LAND_WINDOW_MAIN;
995 else if (strcasecmp(str,
"bar")==0)
996 win = LAND_WINDOW_BAR;
997 else if (strcasecmp(str,
"missions")==0)
998 win = LAND_WINDOW_MISSION;
999 else if (strcasecmp(str,
"outfits")==0)
1000 win = LAND_WINDOW_OUTFITS;
1001 else if (strcasecmp(str,
"shipyard")==0)
1002 win = LAND_WINDOW_SHIPYARD;
1003 else if (strcasecmp(str,
"equipment")==0)
1004 win = LAND_WINDOW_EQUIPMENT;
1005 else if (strcasecmp(str,
"commodity")==0)
1006 win = LAND_WINDOW_COMMODITY;
1008 NLUA_INVALID_PARAMETER(L);
1013 lua_pushboolean( L, !ret );
1029static PlayerShip_t *playerL_shipvarShip( lua_State *L,
int idx )
1031 if (lua_isnoneornil(L,idx))
1047 const char *str = luaL_checkstring(L,1);
1065 const char *str = luaL_checkstring(L,1);
1083 const char *str = luaL_checkstring(L,1);
1108 lua_pushstring(L, ships[i].p->name);
1109 lua_setfield(L, -2,
"name");
1112 lua_setfield(L, -2,
"ship");
1114 lua_pushboolean(L, ships[i].deployed);
1115 lua_setfield(L, -2,
"deployed");
1117 lua_rawseti(L, -2, i+1);
1141 str = luaL_optstring(L, 1, NULL);
1148 if ((str==NULL) || (strcmp(str,
player.
p->
name)==0))
1152 if (strcmp(str, ships[i].p->name)==0) {
1160 NLUA_ERROR( L, _(
"Player does not own a ship named '%s'"), str );
1166 for (
int i=0; i<
array_size(p->outfits); i++) {
1167 if (p->outfits[i]->outfit == NULL)
1172 lua_rawseti( L, -2, j++ );
1190 const char *str = luaL_optstring(L, 1, NULL);
1193 if ((str==NULL) || (strcmp(str,
player.
p->
name)==0))
1197 if (strcmp(str, ships[i].p->name)==0) {
1204 NLUA_ERROR( L, _(
"Player does not own a ship named '%s'"), str );
1211 lua_setfield( L, -2,
"time_played" );
1214 lua_setfield( L, -2,
"acquired" );
1217 lua_setfield( L, -2,
"acquired_date" );
1220 lua_setfield( L, -2,
"dmg_done_shield" );
1223 lua_setfield( L, -2,
"dmg_done_armour" );
1226 lua_setfield( L, -2,
"dmg_done" );
1229 lua_setfield( L, -2,
"dmg_taken_shield" );
1232 lua_setfield( L, -2,
"dmg_taken_armour" );
1235 lua_setfield( L, -2,
"dmg_taken" );
1238 lua_setfield( L, -2,
"jumped_times" );
1241 lua_setfield( L, -2,
"landed_times" );
1244 lua_setfield( L, -2,
"death_counter" );
1246 for (
int i=0; i<SHIP_CLASS_TOTAL; i++)
1248 lua_pushinteger( L, destroyed );
1249 lua_setfield( L, -2,
"ships_destroyed" );
1263 const char *shipname = luaL_checkstring(L,1);
1264 int deploy = lua_toboolean(L,2);
1288 lua_rawseti(L, -2, i+1);
1308 int q, unequipped_only;
1312 unequipped_only = lua_toboolean(L, 2);
1315 if (unequipped_only)
1319 lua_pushnumber( L, q );
1338 int q = luaL_optinteger(L, 2, 1);
1364 int q = luaL_optinteger(L, 2, 1);
1367 if (lua_isstring(L, 1)) {
1368 const char *str = luaL_checkstring(L, 1);
1370 if (strcmp(str,
"all")==0) {
1419 const char *name = luaL_optstring(L, 2, _(s->
name));
1420 const char *acquired = luaL_optstring(L, 3, NULL);
1421 int noname = lua_toboolean(L, 4);
1425 }
while (new_ship == NULL);
1427 lua_pushstring( L, new_ship->
p->
name );
1446 const char *str = luaL_checkstring(L,1);
1447 int ignore_cargo= lua_toboolean(L,2);
1450 if (lua_toboolean(L,3))
1470 lua_rawseti( L, -2, j++ );
1486 const char *str = luaL_checkstring(L,1);
1489 NLUA_ERROR(L, _(
"Mission '%s' not found in stack"), str);
1494 lua_pushinteger( L, n );
1496 lua_pushboolean( L, 0 );
1512 const char *str = luaL_checkstring(L, 1);
1515 NLUA_ERROR(L, _(
"Mission '%s' not found in stack"), str);
1534 lua_rawseti(L,-2,i+1);
1550 const char *str= luaL_checkstring(L,1);
1553 NLUA_ERROR(L, _(
"Event '%s' not found in stack"), str);
1572 const char *str = luaL_checkstring(L, 1);
1575 NLUA_ERROR(L, _(
"Event '%s' not found in stack"), str);
1602 lua_pushboolean( L, 0 );
1605 lua_rawseti( L, -2, n++ );
1659 int q = luaL_checkinteger( L, 2 );
1675 int q = luaL_checkinteger( L, 2 );
1691 int q = luaL_checkinteger( L, 2 );
1718 lua_setfield( L, -2,
"c" );
1720 lua_pushinteger( L, q );
1721 lua_setfield( L, -2,
"q" );
1723 lua_rawseti( L, -2, ++n );
1744 lua_pushstring(L,pi->
name);
1745 lua_setfield(L,-2,
"name");
1748 lua_setfield(L,-2,
"quantity");
1750 lua_rawseti(L,-2,i+1);
1765 const char *name = luaL_checkstring(L,1);
1766 int q = luaL_optinteger(L,2,1);
1781 const char *name = luaL_checkstring(L,1);
1782 int q = luaL_optinteger(L,2,1);
1796 const char *name = luaL_checkstring(L,1);
1820 const char *name, *pntname;
1821 int no_simulate, silent;
1827 NLUA_ERROR(L,_(
"Can not teleport the player while landed!"));
1829 NLUA_ERROR(L,_(
"Can not teleport the player while the comm is open!"));
1831 NLUA_ERROR(L,_(
"Can not teleport the player while they are boarded!"));
1844 NLUA_ERROR( L, _(
"Spob '%s' does not belong to a system."), pnt->
name );
1849 else if (lua_isstring(L,1)) {
1850 const char *sysname;
1851 name = lua_tostring(L,1);
1853 if (sysname == NULL) {
1859 NLUA_ERROR( L, _(
"'%s' is not a valid teleportation target."), name );
1864 NLUA_ERROR( L, _(
"Spob '%s' does not belong to a system."), pntname );
1872 NLUA_INVALID_PARAMETER(L);
1874 no_simulate = lua_toboolean(L,2);
1875 silent = lua_toboolean(L,3);
1879 NLUA_ERROR( L, _(
"System '%s' does not exist."), name );
1887 pilot_rmFlag(
player.
p, PILOT_HYPERSPACE );
1888 pilot_rmFlag(
player.
p, PILOT_HYP_BEGIN );
1889 pilot_rmFlag(
player.
p, PILOT_HYP_BRAKE );
1890 pilot_rmFlag(
player.
p, PILOT_HYP_PREP );
1933 if (p->parent == PLAYER_ID) {
1935 vec2_padd( &p->solid->pos, 200.+200.*RNGF(), 2.*M_PI*RNGF() );
1953 lua_pushnumber(L,
dt_mod);
1974 if (!pships[i].deployed)
2014 const char *str = luaL_checkstring(L,1);
2033 const char *caption = luaL_checkstring( L, 1 );
2034 int priority = luaL_optinteger( L, 3, 5 );
2035 const char *key = luaL_optstring( L, 4,
"" );
2036 luaL_checktype( L, 2, LUA_TFUNCTION );
2037 lua_pushvalue( L, 2 );
2039 lua_pushinteger( L,
id );
2051 int id = luaL_checkinteger(L,1);
2054 WARN(_(
"Failed to unregister info button with id '%d'!"),
id);
2079 const char *savename = luaL_optstring( L, 1,
"autosave" );
2080 Spob *savespob = NULL;
2082 if (!lua_isnoneornil(L,2))
2085 if (!
landed && (savespob==NULL))
2086 NLUA_ERROR(L,_(
"Unable to save when not landed and land spob is not specified!"));
2088 NLUA_ERROR(L,_(
"Unable to save when landed and land_spob does not match landed spob!"));
2090 if (savespob != NULL) {
2095 if (savespob != NULL)
2111 const char *filename = luaL_checkstring(L,1);
2112 if (strcmp(filename,
"autosave")==0)
2113 NLUA_ERROR(L,_(
"Can not back up save to 'autosave'."));
2114 snprintf( file,
sizeof(file),
"saves/%s/autosave.ns",
player.
name );
2115 snprintf( backup,
sizeof(backup),
"saves/%s/%s.ns",
player.
name, filename );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
int player_isBoarded(void)
Gets if the player is boarded.
void board_unboard(void)
Forces unboarding of the pilot.
int comm_isOpen(void)
Check to see if the comm window is open.
void comm_queueClose(void)
Queues a close command when possible.
int event_alreadyRunning(int data)
Check to see if an event is already running.
int event_dataID(const char *evdata)
Gets the event data id from name.
void events_trigger(EventTrigger_t trigger)
Runs all the events matching a trigger.
void gui_clearMessages(void)
Clears the GUI messages.
void gui_reload(void)
Reloads the GUI.
void player_messageRaw(const char *str)
Adds a mesg to the queue to be displayed on screen.
void player_messageToggle(int enable)
Toggles if player should receive messages.
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
int hooks_run(const char *stack)
Runs all the hooks of stack.
int info_buttonRegister(const char *caption, int priority, SDL_Keycode key)
Registers a button in the info menu.
int info_buttonUnregister(int id)
Unregisters a button in the info menu.
void land_queueTakeoff(void)
Queue a takeoff.
int land_setWindow(int window)
Sets the land window tab.
void outfits_updateEquipmentOutfits(void)
Updates the outfitter and equipment outfit image arrays.
int lvar_addArray(lvar **arr, lvar *new_var, int sort)
Adds a var to a var array.
void lvar_rmArray(lvar **arr, lvar *rm_var)
Removes a var from a var array.
lvar * lvar_get(lvar *arr, const char *str)
Gets a lua var by name.
lvar lvar_tovar(lua_State *L, const char *name, int idx)
Gets a lua variable from an index from a lua state.
int lvar_push(lua_State *L, const lvar *v)
Pushes a lua var to a lua state.
Mission ** player_missions
const MissionData * mission_getFromName(const char *name)
Gets mission data from a name.
int mission_alreadyRunning(const MissionData *misn)
Checks to see if mission is already running.
void missions_run(MissionAvailability loc, int faction, const Spob *pnt, const StarSystem *sys)
Runs missions matching location, all Lua side and one-shot.
int mission_getID(const char *name)
Gets id from mission name.
const MissionData * mission_get(int id)
Gets a MissionData based on ID.
Header file with generic functions and naev-specifics.
int ndata_copyIfExists(const char *file1, const char *file2)
Copy a file, if it exists.
Commodity ** lua_pushcommodity(lua_State *L, Commodity *commodity)
Pushes a commodity on the stack.
Commodity * luaL_validcommodity(lua_State *L, int ind)
Makes sure the commodity is valid or raises a Lua error.
const Outfit * luaL_validoutfit(lua_State *L, int ind)
Makes sure the outfit is valid or raises a Lua error.
const Outfit ** lua_pushoutfit(lua_State *L, const Outfit *outfit)
Pushes a outfit on the stack.
LuaPilot * lua_pushpilot(lua_State *L, LuaPilot pilot)
Pushes a pilot on the stack.
static int playerL_shipDeploy(lua_State *L)
Sets the deployed status of a player's ship.
static int playerL_outfitAdd(lua_State *L)
Adds an outfit to the player's outfit list.
static int playerL_evtActive(lua_State *L)
Checks to see if the player has an event active.
static int playerL_shipvarPush(lua_State *L)
Pushes a ship variable.
static int playerL_shipMetadata(lua_State *L)
Gets meta-data about one of the player's ships.
static int playerL_unboard(lua_State *L)
Unboards the player from its boarded target.
static int playerL_fleetCargoAdd(lua_State *L)
Tries to add an amount of commodity to the player's fleet.
static int playerL_fleetCapacitySet(lua_State *L)
Sets the fleet capacity of the player.
static int playerL_fleetCargoRm(lua_State *L)
Tries to remove an amount of commodity to the player's fleet.
static int playerL_missions(lua_State *L)
Gets the list of the player's active missions.
static int playerL_inventoryRm(lua_State *L)
Removes an item to the player's in-game inventory.
static int playerL_msg(lua_State *L)
Sends the player an in-game message.
static int playerL_inventory(lua_State *L)
Gets the contents of the player's inventory.
static int playerL_shipSwap(lua_State *L)
Swaps the player's current ship with a ship they own by name.
static int playerL_credits(lua_State *L)
Gets how many credits the player has on him.
static int playerL_outfits(lua_State *L)
Gets all the outfits the player owns.
static int playerL_saveBackup(lua_State *L)
Backs up the player's last autosave with a custom name.
static int playerL_pay(lua_State *L)
Pays the player an amount of money.
static int playerL_shipname(lua_State *L)
Gets the player's ship's name (given by the player).
static int playerL_setSpeed(lua_State *L)
Sets the game speed directly.
static int playerL_fuel(lua_State *L)
Gets the amount of fuel a player has.
static int playerL_canDiscover(lua_State *L)
Global toggle to whether or not the player can discover space objects and jumps. Meant to be used wit...
static int playerL_isLanded(lua_State *L)
Checks to see if the player is landed or not.
static int playerL_infoButtonUnregister(lua_State *L)
Unregisters a button in the info window.
static int playerL_damageSPFX(lua_State *L)
Applies the damage effects to the player.
static int playerL_ships(lua_State *L)
Gets the names of the player's ships.
static int playerL_takeoff(lua_State *L)
Forces the player to take off if they are landed.
static int playerL_cinematics(lua_State *L)
Puts the game in cinematics mode or back to regular mode.
static int playerL_fleetCapacity(lua_State *L)
Gets the fleet capacity (and used) of the player.
static int playerL_inventoryAdd(lua_State *L)
Adds an item to the player's in-game inventory.
static int playerL_commclose(lua_State *L)
Forces the player to close comm if they are chatting.
static int playerL_autonavAbort(lua_State *L)
Stops the players autonav if active.
static int playerL_allowLand(lua_State *L)
Allows or disallows the player to land.
static int playerL_jumps(lua_State *L)
Gets a player's jump range based on their remaining fuel.
static int playerL_fleetCargoJet(lua_State *L)
Tries to remove an amount of commodity to the player's fleet and jettisons it into space.
static const luaL_Reg playerL_methods[]
static int playerL_landWindow(lua_State *L)
Sets the active land window.
static int playerL_outfitRm(lua_State *L)
Removes an outfit from the player's outfit list.
static int playerL_refuel(lua_State *L)
Refuels the player.
static int playerL_msgToggle(lua_State *L)
Clears the player's message buffer.
static int playerL_dt_mod(lua_State *L)
Gets the dt_mod of the player, which multiplies all time stuff.
static int playerL_teleport(lua_State *L)
Teleports the player to a new spob or system (only if not landed).
static int playerL_getPilot(lua_State *L)
Gets the player's associated pilot.
int nlua_loadPlayer(nlua_env env)
Loads the player Lua library.
static int playerL_chapterSet(lua_State *L)
Sets the player's current chapter.
static int playerL_infoButtonRegister(lua_State *L)
Registers a button in the info window.
static int playerL_shipvarPeek(lua_State *L)
Peeks at a ship variable.
static int playerL_omsgRm(lua_State *L)
Removes an overlay message.
static int playerL_omsgChange(lua_State *L)
Changes an overlay message.
static int playerL_fleetList(lua_State *L)
Lists the ships in the player's fleet.
static int playerL_misnDoneList(lua_State *L)
Gets a list of all the missions the player has done.
static int playerL_fleetCargoList(lua_State *L)
Gets the list of all the cargos in the player's fleet.
static int playerL_chapter(lua_State *L)
Gets the player's current chapter.
static int playerL_getname(lua_State *L)
Lua bindings to interact with the player.
static int playerL_omsgAdd(lua_State *L)
Adds an overlay message.
static int playerL_fleetCargoUsed(lua_State *L)
Gets the amount of cargo space used in the player's fleet.
static int playerL_fleetCargoFree(lua_State *L)
Gets the amount of cargo space free in the player's fleet.
static int playerL_inventoryOwned(lua_State *L)
Checks to see how much of an item the player has in their inventory.
static int playerL_shipAdd(lua_State *L)
Gives the player a new ship.
static int playerL_allowSave(lua_State *L)
Sets player save ability.
static int playerL_autonavReset(lua_State *L)
Resets the game speed without disabling autonav.
static int playerL_evtDone(lua_State *L)
Checks to see if player has done an event.
static int playerL_getPosition(lua_State *L)
Gets the player's position.
static int playerL_land(lua_State *L)
Automagically lands the player on a spob.
static int playerL_fleetCargoOwned(lua_State *L)
Gets the amount of cargo space used by a specific commodity in the player's fleet.
static int playerL_numOutfit(lua_State *L)
Gets the number of outfits the player owns in their list (excludes equipped on ships).
static int playerL_misnActive(lua_State *L)
Checks to see if the player has a mission active.
static int playerL_wealth(lua_State *L)
Gets how many credits the player owns both directly, and in the form of assets (ships,...
static int playerL_autonav(lua_State *L)
Checks to see if the player has autonav enabled.
static int playerL_msgClear(lua_State *L)
Clears the player's message buffer.
static int playerL_misnDone(lua_State *L)
Checks to see if player has done a mission.
static int playerL_save(lua_State *L)
Saves the game.
static int playerL_autonavDest(lua_State *L)
Gets the player's long term autonav destination.
static int playerL_shipvarPop(lua_State *L)
Pops a ship variable.
static int playerL_screenshot(lua_State *L)
Takes a screenshot (same as the keyboard action).
static int playerL_shipOutfits(lua_State *L)
Gets the outfits for one of the player's ships.
const Ship ** lua_pushship(lua_State *L, const Ship *ship)
Pushes a ship on the stack.
const Ship * luaL_validship(lua_State *L, int ind)
Makes sure the ship is valid or raises a Lua error.
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
Spob * luaL_validspob(lua_State *L, int ind)
Gets a spob directly.
int lua_isspob(lua_State *L, int ind)
Checks to see if ind is a spob.
LuaSystem * lua_pushsystem(lua_State *L, LuaSystem sys)
Pushes a system on the stack.
StarSystem * luaL_validsystem(lua_State *L, int ind)
Gets system (or system name) at index raising an error if type doesn't match.
int lua_issystem(lua_State *L, int ind)
Checks to see if ind is a system.
ntime_t * lua_pushtime(lua_State *L, ntime_t time)
Pushes a time on the stack.
vec2 * lua_pushvector(lua_State *L, vec2 vec)
Pushes a vector on the stack.
void gl_setDefViewport(int x, int y, int w, int h)
Sets the default viewport.
void pause_setSpeed(double mod)
Adjusts the game's dt modifier.
credits_t pilot_worth(const Pilot *p)
Gets the price or worth of a pilot in credits.
void pilot_setCommMsg(Pilot *p, const char *s)
Sets the overhead communication message of the pilot.
static Pilot ** pilot_stack
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
int pilot_getJumps(const Pilot *p)
Gets the amount of jumps the pilot has left.
void pilot_clearTrails(Pilot *p)
Resets the trails for a pilot.
void pilot_outfitLOnjumpin(Pilot *pilot)
Runs Lua outfits when pilot jumps into a system.
int player_eventAlreadyDone(int id)
Checks to see if player has already completed a event.
int player_rmOutfit(const Outfit *o, int quantity)
Remove an outfit from the player's outfit stack.
void player_swapShip(const char *shipname, int move_cargo)
Swaps player's current ship with their ship named shipname.
int player_addOutfit(const Outfit *o, int quantity)
Adds an outfit to the player outfit stack.
void player_resetSpeed(void)
Resets the player speed stuff.
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
PlayerShip_t * player_newShip(const Ship *ship, const char *def_name, int trade, const char *acquired, int noname)
Creates a new ship for player.
void player_rmShip(const char *shipname)
Removes one of the player's ships.
int player_outfitOwnedTotal(const Outfit *o)
PlayerShip_t * player_getPlayerShip(const char *shipname)
Gets a specific ship.
int player_missionAlreadyDone(int id)
Checks to see if player has already completed a mission.
credits_t player_modCredits(credits_t amount)
Modifies the amount of credits the player has.
void player_accelOver(void)
Done accelerating.
int player_outfitOwned(const Outfit *o)
Gets how many of the outfit the player owns.
void player_targetClearAll(void)
Clears all player targets: hyperspace, spob, asteroid, etc...
void player_nolandMsg(const char *str)
Sets the no land message.
const PlayerOutfit_t * player_getOutfits(void)
Gets an array (array.h) of the player's outfits.
void player_screenshot(void)
Takes a screenshot.
int * player_missionsDoneList(void)
Gets a list of all the missions the player has done.
void player_autonavEnd(void)
Ends the autonav.
void player_autonavResetSpeed(void)
Resets the game speed.
void player_autonavAbort(const char *reason)
Aborts autonav.
int pfleet_cargoFree(void)
Gets the total amount of free cargo space in the player's fleet.
int pfleet_cargoOwned(const Commodity *com)
Gets the total amount of a commodity type owned by the player's fleet.
int pfleet_cargoAdd(const Commodity *com, int q)
Adds some cargo to the player's fleet.
int pfleet_cargoRm(const Commodity *com, int q, int jet)
Removes some cargo from the player's fleet.
int pfleet_cargoUsed(void)
Gets the total cargo space used by the player's fleet.
void pfleet_update(void)
Updates the used fleet capacity of the player.
int player_inventoryAdd(const char *name, int amount)
Adds an item to the player inventory.
int player_inventoryRemove(const char *name, int amount)
Removes an item from the player inventory.
const PlayerItem * player_inventory(void)
Gets the whole player inventory.
int player_inventoryAmount(const char *name)
Gets the amount of an item the player has.
int save_all_with_name(const char *name)
Saves the current game.
void sound_setSpeed(double s)
Sets the speed to play the sound at.
void space_init(const char *sysname, int do_simulate)
Initializes the system.
void space_gfxUnload(StarSystem *sys)
Unloads all the graphics for a star system.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
StarSystem * system_getIndex(int id)
Get the system by its index.
int spob_index(const Spob *p)
Gets the ID of a spob.
const char * system_existsCase(const char *sysname)
Checks to see if a system exists case insensitively.
StarSystem * system_get(const char *sysname)
Get the system from its name.
char * spob_getSystem(const char *spobname)
Get the name of a system from a spobname.
void space_queueLand(Spob *pnt)
Cues a spob to be landed on. This is not done immediately, but when the engine thinks it is ok to do.
void spob_luaInitMem(const Spob *spob)
Initializes the memory fo a spob.
int system_index(const StarSystem *sys)
Gets the index of a star system.
void spfx_shake(double mod)
Increases the current rumble level.
void spfx_damage(double mod)
Increases the current damage level.
The actual hook parameter.
A ship outfit, depends radically on the type.
The representation of an in-game pilot.
Represents an item in the player inventory.
unsigned int death_counter
unsigned int landed_times
unsigned int ships_destroyed[SHIP_CLASS_TOTAL]
unsigned int jumped_times
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Contains a mission variable.