19#include "nlua_player.h"
30#include "land_outfits.h"
33#include "map_overlay.h"
37#include "nlua_colour.h"
38#include "nlua_commodity.h"
39#include "nlua_outfit.h"
40#include "nlua_pilot.h"
43#include "nlua_system.h"
51#include "player_fleet.h"
52#include "player_inventory.h"
53#include "player_gui.h"
57#define PLAYER_CHECK() if (player.p == NULL) return 0
86static int playerL_dt_default( lua_State *L );
87static int playerL_speed( lua_State *L );
184 {
"dt_default", playerL_dt_default },
185 {
"speed", playerL_speed },
315 money =
CLAMP( CREDITS_MIN, CREDITS_MAX, (credits_t)round(luaL_checknumber(L,1)) );
317 if (lua_isstring(L,2)) {
319 reason = lua_tostring(L,2);
322 nohooks = lua_toboolean(L,2);
328 p[0].type = HOOK_PARAM_NUMBER;
329 p[0].u.num = (double)money;
330 if (reason != NULL) {
331 p[1].type = HOOK_PARAM_STRING;
335 p[1].type = HOOK_PARAM_NIL;
337 p[2].type = HOOK_PARAM_SENTINEL;
360 int decimals = luaL_optinteger(L,1,-1);
363 lua_pushnumber(L, creds);
365 char buf[ ECON_CRED_STRLEN ];
367 lua_pushstring(L, buf);
388 int decimals = luaL_optinteger(L,1,-1);
399 wealth += po[i].q * po[i].o->price;
405 lua_pushnumber(L, wealth);
407 char buf[ ECON_CRED_STRLEN ];
409 lua_pushstring(L, buf);
426 const char *str = luaL_checkstring(L,1);
427 int display = lua_toboolean(L,2);
480 str = luaL_checkstring(L,1);
481 duration = luaL_optnumber(L,2,10.);
482 fontsize = luaL_optinteger(L,3,OMSG_FONT_DEFAULT_SIZE);
483 col = luaL_optcolour(L,4,&cWhite);
486 if (duration < 1e-10)
490 id = omsg_add( str, duration, fontsize, col );
491 lua_pushnumber( L,
id );
514 id = luaL_checklong(L,1);
515 str = luaL_checkstring(L,2);
516 duration = luaL_checknumber(L,3);
519 if (duration < 1e-10)
523 ret = omsg_change(
id, str, duration );
524 lua_pushboolean(L,!ret);
537 unsigned int id = luaL_checklong(L,1);
552 if (lua_gettop(L)==0)
555 b = lua_toboolean(L, 1);
558 player_rmFlag(PLAYER_NOSAVE);
560 player_setFlag(PLAYER_NOSAVE);
603 lua_pushnumber(L, 0);
644 if (lua_gettop(L) > 0) {
645 double f = luaL_checknumber(L,1);
667 lua_pushboolean( L, player_isFlag( PLAYER_AUTONAV ) );
679 const vec2 *pos = luaL_optvector(L,1,NULL);
683 ovr_autonavPos( pos->
x, pos->
y );
703 dest = map_getDestination( &jumps );
709 lua_pushnumber( L, jumps );
725 const char *str = luaL_optstring(L,1,NULL);
740 double timer = luaL_optnumber(L,1,0.);
741 player_autonavReset( timer );
758static int playerL_dt_default( lua_State *L )
764static int playerL_speed( lua_State *L )
780 double speed = luaL_optnumber( L, 1, -1 );
781 double sound = luaL_optnumber( L, 2, speed );
782 int noset = lua_toboolean( L, 3 );
818 const char *abort_msg;
828 b = lua_toboolean( L, 1 );
829 if (!lua_isnoneornil(L,2)) {
830 if (!lua_istable(L,2))
831 return NLUA_ERROR( L, _(
"Second parameter to cinematics should be a table of options or omitted!") );
833 lua_getfield( L, 2,
"abort" );
834 if (!lua_isnil( L, -1 ))
835 abort_msg = luaL_checkstring( L, -1 );
838 lua_getfield( L, 2,
"gui" );
839 f_gui = lua_toboolean(L, -1);
842 lua_getfield( L, 2,
"no2x" );
843 f_2x = lua_toboolean(L, -1);
846 lua_getfield( L, 2,
"speed" );
847 speed = luaL_optnumber(L,-1,1.);
862 player_setFlag( PLAYER_CINEMATICS );
864 player_setFlag( PLAYER_CINEMATICS_GUI );
866 player_setFlag( PLAYER_CINEMATICS_2X );
876 player_rmFlag( PLAYER_CINEMATICS );
877 player_rmFlag( PLAYER_CINEMATICS_GUI );
878 player_rmFlag( PLAYER_CINEMATICS_2X );
892 lua_pushboolean( L, player_isFlag( PLAYER_CINEMATICS ) );
904 double spfx_mod = luaL_checknumber(L,1);
933 case PLAYER_BOARD_IMPOSSIBLE:
934 lua_pushstring(L,
"impossible");
936 case PLAYER_BOARD_RETRY:
937 lua_pushstring(L,
"retry");
939 case PLAYER_BOARD_OK:
940 lua_pushstring(L,
"ok");
943 lua_pushstring(L,
"error");
973 lua_pushboolean( L,
landed );
990 return NLUA_ERROR(L,_(
"Player must be landed to force takeoff."));
992 return NLUA_ERROR(L,_(
"Player must be spaceworthy to force takeoff!"));
1010 case PLAYER_LAND_DENIED:
1011 lua_pushstring(L,
"impossible");
1013 case PLAYER_LAND_OK:
1014 lua_pushstring(L,
"ok");
1016 case PLAYER_LAND_AGAIN:
1017 lua_pushstring(L,
"retry");
1020 lua_pushstring(L,
"error");
1040 if (sysname == NULL)
1041 return NLUA_ERROR(L,_(
"Spob '%s' is not in a system!"), spob->
name);
1048 pilot_rmFlag(
player.
p, PILOT_HYPERSPACE );
1049 pilot_rmFlag(
player.
p, PILOT_HYP_BEGIN );
1050 pilot_rmFlag(
player.
p, PILOT_HYP_BRAKE );
1051 pilot_rmFlag(
player.
p, PILOT_HYP_PREP );
1082 lua_rawgeti(naevL, LUA_REGISTRYINDEX, spob->
lua_land);
1085 if (nlua_pcall( spob->
lua_env, 2, 0 )) {
1086 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), spob->
name,
"land", lua_tostring(naevL,-1));
1114 const char *str = NULL;
1116 if (lua_gettop(L) > 0) {
1117 b = lua_toboolean(L,1);
1118 if (lua_isstring(L,2))
1119 str = lua_tostring(L,2);
1125 player_rmFlag( PLAYER_NOLAND );
1127 player_setFlag( PLAYER_NOLAND );
1157 return NLUA_ERROR(L, _(
"Must be landed to set the active land window."));
1159 str = luaL_checkstring(L,1);
1160 if (strcasecmp(str,
"main")==0)
1161 win = LAND_WINDOW_MAIN;
1162 else if (strcasecmp(str,
"bar")==0)
1163 win = LAND_WINDOW_BAR;
1164 else if (strcasecmp(str,
"missions")==0)
1165 win = LAND_WINDOW_MISSION;
1166 else if (strcasecmp(str,
"outfits")==0)
1167 win = LAND_WINDOW_OUTFITS;
1168 else if (strcasecmp(str,
"shipyard")==0)
1169 win = LAND_WINDOW_SHIPYARD;
1170 else if (strcasecmp(str,
"equipment")==0)
1171 win = LAND_WINDOW_EQUIPMENT;
1172 else if (strcasecmp(str,
"commodity")==0)
1173 win = LAND_WINDOW_COMMODITY;
1175 NLUA_INVALID_PARAMETER(L,1);
1180 lua_pushboolean( L, !ret );
1196static PlayerShip_t *playerL_shipvarShip( lua_State *L,
int idx )
1198 if (lua_isnoneornil(L,idx))
1215 const char *str = luaL_checkstring(L,1);
1234 const char *str = luaL_checkstring(L,1);
1253 const char *str = luaL_checkstring(L,1);
1281 lua_pushstring(L, ships[i].p->name);
1282 lua_setfield(L, -2,
"name");
1285 lua_setfield(L, -2,
"ship");
1287 lua_pushboolean(L, ships[i].deployed);
1288 lua_setfield(L, -2,
"deployed");
1290 lua_rawseti(L, -2, i+1);
1317 str = luaL_optstring(L, 1, NULL);
1324 if ((str==NULL) || (strcmp(str,
player.
p->
name)==0))
1328 if (strcmp(str, ships[i].p->name)==0) {
1336 return NLUA_ERROR( L, _(
"Player does not own a ship named '%s'"), str );
1340 for (
int i=0; i<
array_size(p->outfits); i++) {
1341 if (p->outfits[i]->outfit == NULL)
1346 lua_rawseti( L, -2, j++ );
1364 const char *str = luaL_optstring(L, 1, NULL);
1367 if ((str==NULL) || (strcmp(str,
player.
p->
name)==0))
1371 if (strcmp(str, ships[i].p->name)==0) {
1378 return NLUA_ERROR( L, _(
"Player does not own a ship named '%s'"), str );
1383 lua_setfield( L, -2,
"time_played" );
1386 lua_setfield( L, -2,
"acquired" );
1389 lua_setfield( L, -2,
"acquired_date" );
1392 lua_setfield( L, -2,
"dmg_done_shield" );
1395 lua_setfield( L, -2,
"dmg_done_armour" );
1398 lua_setfield( L, -2,
"dmg_done" );
1401 lua_setfield( L, -2,
"dmg_taken_shield" );
1404 lua_setfield( L, -2,
"dmg_taken_armour" );
1407 lua_setfield( L, -2,
"dmg_taken" );
1410 lua_setfield( L, -2,
"jumped_times" );
1413 lua_setfield( L, -2,
"landed_times" );
1416 lua_setfield( L, -2,
"death_counter" );
1418 for (
int i=0; i<SHIP_CLASS_TOTAL; i++)
1420 lua_pushinteger( L, destroyed );
1421 lua_setfield( L, -2,
"ships_destroyed" );
1436 const char *shipname = luaL_checkstring(L,1);
1437 int deploy = lua_toboolean(L,2);
1462 int unequipped_only = lua_toboolean(L, 1);
1469 lua_rawseti(L, -2, n++);
1472 if (!unequipped_only) {
1474 for (
int j=0; j<
array_size(pstack[i].p->outfits); j++) {
1478 if (outfits[k].o==o) {
1485 lua_rawseti(L, -2, n++);
1506 lua_pushnumber(L,0.);
1511 int q, unequipped_only;
1515 unequipped_only = lua_toboolean(L, 2);
1518 if (unequipped_only)
1522 lua_pushnumber( L, q );
1542 int q = luaL_optinteger(L, 2, 1);
1566 int q = luaL_optinteger(L, 2, 1);
1569 if (lua_isstring(L, 1)) {
1570 const char *str = luaL_checkstring(L, 1);
1572 if (strcmp(str,
"all")==0) {
1621 const char *name = luaL_optstring(L, 2, _(s->
name));
1622 const char *acquired = luaL_optstring(L, 3, NULL);
1623 int noname = lua_toboolean(L, 4);
1627 }
while (new_ship == NULL);
1629 lua_pushstring( L, new_ship->
p->
name );
1648 const char *str = luaL_checkstring(L,1);
1649 int ignore_cargo= lua_toboolean(L,2);
1652 if (lua_toboolean(L,3))
1680 misn_pushMissionData( L, md );
1682 if (pm->
title != NULL) {
1683 lua_pushstring( L, pm->
title );
1684 lua_setfield(L,-2,
"title");
1686 if (pm->
desc != NULL) {
1687 lua_pushstring( L, pm->
desc );
1688 lua_setfield(L,-2,
"desc");
1690 if (pm->
reward != NULL) {
1691 lua_pushstring( L, pm->
reward );
1692 lua_setfield(L,-2,
"reward");
1694 lua_rawseti( L, -2, j++ );
1711 const char *str = luaL_checkstring(L,1);
1714 return NLUA_ERROR(L, _(
"Mission '%s' not found in stack"), str);
1717 lua_pushinteger( L, n );
1719 lua_pushboolean( L, 0 );
1736 const char *str = luaL_checkstring(L, 1);
1739 return NLUA_ERROR(L, _(
"Mission '%s' not found in stack"), str);
1760 lua_rawseti(L,-2,i+1);
1777 const char *str= luaL_checkstring(L,1);
1780 return NLUA_ERROR(L, _(
"Event '%s' not found in stack"), str);
1798 const char *str = luaL_checkstring(L, 1);
1801 return NLUA_ERROR(L, _(
"Event '%s' not found in stack"), str);
1821 event_toLuaTable( L, done[i] );
1822 lua_rawseti(L,-2,i+1);
1851 lua_pushstring( L, gui[i] );
1852 lua_rawseti( L, -2, i+1 );
1866 const char *name = luaL_checkstring(L,1);
1868 return NLUA_ERROR(L,_(
"GUI '%s' does not exist!"),name);
1899 lua_pushboolean( L, 0 );
1902 lua_rawseti( L, -2, n++ );
1916 lua_pushinteger(L,0);
1931 lua_pushinteger(L,0);
1948 lua_pushinteger(L,0);
1965 int q = luaL_checkinteger( L, 2 );
1967 lua_pushinteger(L,0);
1984 int q = luaL_checkinteger( L, 2 );
1986 lua_pushinteger(L,0);
2003 int q = luaL_checkinteger( L, 2 );
2005 lua_pushinteger(L,0);
2037 lua_setfield( L, -2,
"c" );
2039 lua_pushinteger( L, q );
2040 lua_setfield( L, -2,
"q" );
2042 lua_rawseti( L, -2, ++n );
2067 lua_pushstring(L,pi->
name);
2068 lua_setfield(L,-2,
"name");
2071 lua_setfield(L,-2,
"quantity");
2073 lua_rawseti(L,-2,i+1);
2088 const char *name = luaL_checkstring(L,1);
2089 int q = luaL_optinteger(L,2,1);
2091 lua_pushinteger( L, 0 );
2107 const char *name = luaL_checkstring(L,1);
2108 int q = luaL_optinteger(L,2,1);
2110 lua_pushinteger( L, 0 );
2125 const char *name = luaL_checkstring(L,1);
2127 lua_pushinteger( L, 0 );
2153 const char *name, *pntname;
2154 int no_simulate, silent;
2158 return NLUA_ERROR(L,_(
"Can not teleport the player while landed!"));
2160 return NLUA_ERROR(L,_(
"Can not teleport the player while the comm is open!"));
2162 return NLUA_ERROR(L,_(
"Can not teleport the player while they are boarded!"));
2175 return NLUA_ERROR( L, _(
"Spob '%s' does not belong to a system."), pnt->
name );
2178 else if (lua_isstring(L,1)) {
2179 const char *sysname;
2180 name = lua_tostring(L,1);
2182 if (sysname == NULL) {
2188 return NLUA_ERROR( L, _(
"'%s' is not a valid teleportation target."), name );
2191 return NLUA_ERROR( L, _(
"Spob '%s' does not belong to a system."), pntname );
2197 NLUA_INVALID_PARAMETER(L,1);
2199 no_simulate = lua_toboolean(L,2);
2200 silent = lua_toboolean(L,3);
2204 return NLUA_ERROR( L, _(
"System '%s' does not exist."), name );
2213 pilot_rmFlag(
player.
p, PILOT_HYPERSPACE );
2214 pilot_rmFlag(
player.
p, PILOT_HYP_BEGIN );
2215 pilot_rmFlag(
player.
p, PILOT_HYP_BRAKE );
2216 pilot_rmFlag(
player.
p, PILOT_HYP_PREP );
2259 if (p->parent == PLAYER_ID) {
2261 vec2_padd( &p->solid.pos, 200.+200.*RNGF(), 2.*M_PI*RNGF() );
2279 lua_pushnumber(L,
dt_mod);
2300 if (!pships[i].deployed)
2340 const char *str = luaL_checkstring(L,1);
2359 const char *caption = luaL_checkstring( L, 1 );
2360 int priority = luaL_optinteger( L, 3, 5 );
2361 const char *key = luaL_optstring( L, 4,
"" );
2362 luaL_checktype( L, 2, LUA_TFUNCTION );
2363 lua_pushvalue( L, 2 );
2364 id = info_buttonRegister( caption, priority, SDL_GetKeyFromName( key ) );
2365 lua_pushinteger( L,
id );
2377 int id = luaL_checkinteger(L,1);
2378 int ret = info_buttonUnregister(
id );
2380 WARN(_(
"Failed to unregister info button with id '%d'!"),
id);
2405 const char *savename = luaL_optstring( L, 1,
"autosave" );
2406 Spob *savespob = NULL;
2407 Spob *prevspob = NULL;
2408 if (!lua_isnoneornil(L,2))
2411 if (!
landed && (savespob==NULL))
2412 return NLUA_ERROR(L,_(
"Unable to save when not landed and land spob is not specified!"));
2413 else if (
landed && (savespob!=NULL))
2414 return NLUA_ERROR(L,_(
"Unable to save when landed and land_spob does not match landed spob!"));
2416 if (savespob != NULL) {
2421 if (savespob != NULL)
2437 const char *filename = luaL_checkstring(L,1);
2438 if (strcmp(filename,
"autosave")==0)
2439 return NLUA_ERROR(L,_(
"Can not back up save to 'autosave'."));
2440 snprintf( file,
sizeof(file),
"saves/%s/autosave.ns",
player.
name );
2441 snprintf( backup,
sizeof(backup),
"saves/%s/%s.ns",
player.
name, filename );
2454 player_setFlag( PLAYER_DESTROYED );
2472 lua_setfield( L, -2,
"name" );
2475 lua_setfield( L, -2,
"ship" );
2478 lua_setfield( L, -2,
"shipname" );
2481 lua_setfield( L, -2,
"acquired" );
2484 lua_setfield( L, -2,
"gui" );
2487 lua_setfield( L, -2,
"credits" );
2490 lua_setfield( L, -2,
"date" );
2493 lua_setfield( L, -2,
"system" );
2496 vec2_cset( &v, x, y );
2498 lua_setfield( L, -2,
"position" );
2502 lua_setfield( L, -2,
"mission" );
2507 lua_setfield( L, -2,
"event" );
2511 lua_setfield( L, -2,
"chapter" );
2514 lua_setfield( L, -2,
"spob_lua_default" );
2517 lua_setfield( L, -2,
"dtype_default" );
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_tryBoard(int noisy)
Attempt to board the player's target.
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.
Commodity * commodity_getAll(void)
Gets all the commodities.
void credits2str(char *str, credits_t credits, int decimals)
Converts credits to a usable string for displaying.
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.
const char * gui_pick(void)
Determines which GUI should be used.
int gui_exists(const char *name)
Checks to see if a GUI exists.
int gui_load(const char *name)
Attempts to load the actual GUI.
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.
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, const 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(const 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_cinematicsCheck(lua_State *L)
Checks to see if the game is in cinematics mode.
static int playerL_inventory(lua_State *L)
Gets the contents of the player's inventory.
static int playerL_autonavSetPos(lua_State *L)
Indicates the player where their autonav target position is.
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_autonavEnd(lua_State *L)
Ends the autonav system. You probably want to use player.autonavAbort instead of this.
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_landAllow(lua_State *L)
Allows or disallows the player to land.
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_evtDoneList(lua_State *L)
Gets a list of all the events the player has done.
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_gui(lua_State *L)
Gets the player's current GUI.
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_tryLand(lua_State *L)
Tries to make the player land.
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_tryBoard(lua_State *L)
Tries to make the player board their target.
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_start(lua_State *L)
Gets information about the player's starting point.
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_outfitNum(lua_State *L)
Gets the number of outfits the player owns in their list (excludes equipped on ships).
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_guiList(lua_State *L)
Lists the GUIs the player can use.
static int playerL_guiSet(lua_State *L)
Sets the player's GUI.
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_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_gameover(lua_State *L)
Gives the player a game over message.
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.
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.
credits_t pilot_worth(const Pilot *p, int count_unique)
Gets the price or worth of a pilot in credits.
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_destealth(Pilot *p)
Destealths a pilot.
void pilot_outfitLOnjumpin(Pilot *pilot)
Runs Lua outfits when pilot jumps into a system.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
int pilot_isSpaceworthy(const Pilot *p)
Pilot safety check - makes sure stats are safe.
void pilot_afterburnOver(Pilot *p)
Deactivates the afterburner.
int pilot_outfitOffAll(Pilot *p)
Disables all active outfits for a pilot.
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.
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
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.
int * player_eventsDoneList(void)
Gets a list of all the events the player has done.
void player_accelOver(void)
Done accelerating.
int player_land(int loud)
Try to land or target closest spob if no land target.
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_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.
const char ** player_guiList(void)
Gets the list of GUIs.
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.
const Ship * ship_get(const char *name)
Gets a ship based on its name.
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.
const 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.
const char * start_acquired(void)
Gets the module's starting ship was acquired.
const char * start_event(void)
Gets the starting event of the player.
const char * start_mission(void)
Gets the starting mission of the player.
void start_position(double *x, double *y)
Gets the starting position of the player.
const char * start_chapter(void)
Gets the player's starting chapter.
const char * start_name(void)
Gets the module name.
const char * start_dtype_default(void)
Gets the default damage type.
const char * start_ship(void)
Gets the module player starting ship.
ntime_t start_date(void)
Gets the starting date.
const char * start_spob_lua_default(void)
Gets the default spob Lua file.
const char * start_shipname(void)
Gets the module's starting ship's name.
const char * start_gui(void)
Gets the module's starting ship was acquired.
const char * start_system(void)
Gets the starting system name.
unsigned int start_credits(void)
Gets the player's starting credits.
The actual hook parameter.
Represents an active mission.
A ship outfit, depends radically on the type.
The representation of an in-game pilot.
PilotOutfitSlot ** outfits
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.