naev 0.12.6
nlua_pilot.c File Reference

Handles the Lua pilot bindings. More...

#include "nlua_pilot.h"
#include "ai.h"
#include "array.h"
#include "camera.h"
#include "damagetype.h"
#include "escort.h"
#include "gui.h"
#include "land_outfits.h"
#include "map.h"
#include "nlua.h"
#include "nlua_asteroid.h"
#include "nlua_canvas.h"
#include "nlua_colour.h"
#include "nlua_commodity.h"
#include "nlua_faction.h"
#include "nlua_jump.h"
#include "nlua_outfit.h"
#include "nlua_pilotoutfit.h"
#include "nlua_ship.h"
#include "nlua_spob.h"
#include "nlua_system.h"
#include "nlua_tex.h"
#include "nlua_vec2.h"
#include "nluadef.h"
#include "pilot.h"
#include "pilot_heat.h"
#include "player.h"
#include "player_autonav.h"
#include "rng.h"
#include "space.h"
#include "weapon.h"
Include dependency graph for nlua_pilot.c:

Go to the source code of this file.

Data Structures

struct  pL_flag
 Small struct to handle flags. More...

Macros

#define PUSH_DOUBLE(L, name, value)
#define PUSH_INT(L, name, value)

Functions

static int pilotL_getFriendOrFoe (lua_State *L, int friend)
static TaskpilotL_newtask (lua_State *L, Pilot *p, const char *task)
 Does a new task.
static int outfit_compareActive (const void *slot1, const void *slot2)
 qsort compare function for active outfits.
static int pilotL_setFlagWrapper (lua_State *L, int flag)
 Wrapper to simplify flag setting stuff.
static int pilot_outfitAddSlot (Pilot *p, const Outfit *o, PilotOutfitSlot *s, int bypass_cpu, int bypass_slot)
 Adds an outfit to a specific slot.
static int luaL_checkweapset (lua_State *L, int idx)
static PilotOutfitSlotluaL_checkslot (lua_State *L, Pilot *p, int idx)
static int pilotL_add (lua_State *L)
 Adds a ship with an AI and faction to the system (instead of a predefined fleet).
static int pilotL_clone (lua_State *L)
 Clones a pilot. It will share nearly all properties including outfits.
static int pilotL_remove (lua_State *L)
 Removes a pilot without explosions or anything.
static int pilotL_explode (lua_State *L)
 Removes a pilot as if it exploded.
static int pilotL_clear (lua_State *L)
 Clears the current system of pilots. Used for epic battles and such.
static int pilotL_clearSelect (lua_State *L)
 Removes all pilots belonging to a faction from the system.
static int pilotL_canSpawn (lua_State *L)
 Returns if pilots can can spawn naturally in the current system.
static int pilotL_toggleSpawn (lua_State *L)
 Disables or enables pilot spawning in the current system.
static int pilotL_getPilots (lua_State *L)
 Gets the pilots available in the system by a certain criteria.
static int pilotL_getAllies (lua_State *L)
 Gets friendly pilots to a pilot (or faction) within a certain distance.
static int pilotL_getEnemies (lua_State *L)
 Gets hostile pilots to a pilot (or faction) within a certain distance.
static int pilotL_getVisible (lua_State *L)
 Gets visible pilots to a pilot.
static int pilotL_getInrange (lua_State *L)
 Gets visible pilots to a pilot within a certain distance.
static int pilotL_eq (lua_State *L)
 Checks to see if pilot and p are the same.
static int pilotL_tostring (lua_State *L)
 Gets the pilot's current (translated) name or notes it is inexistent.
static int pilotL_name (lua_State *L)
 Gets the pilot's current (translated) name.
static int pilotL_id (lua_State *L)
 Gets the ID of the pilot. Guaranteed to be unique per pilot and not repeating over time (with the exception of the player).
static int pilotL_exists (lua_State *L)
 Checks to see if pilot is still in the system and alive.
static int pilotL_target (lua_State *L)
 Gets the pilot target of the pilot.
static int pilotL_setTarget (lua_State *L)
 Sets the pilot target of the pilot.
static int pilotL_targetAsteroid (lua_State *L)
 Gets the asteroid target of the pilot.
static int pilotL_setTargetAsteroid (lua_State *L)
 Sets the pilot's asteroid target.
static int pilotL_inrange (lua_State *L)
 Checks to see if a target pilot is in range of a pilot.
static int pilotL_scandone (lua_State *L)
 Checks to see if a pilot is done scanning its target.
static int pilotL_withPlayer (lua_State *L)
 Checks to see if pilot is with player.
static int pilotL_nav (lua_State *L)
 Gets the nav target of the pilot.
static int pilotL_navSpob (lua_State *L)
 Gets the nav spob target of the pilot.
static int pilotL_navJump (lua_State *L)
 Gets the nav jump target of the pilot.
static int pilotL_navJumpSet (lua_State *L)
 Sets the hyperspace navigation target for the pilot.
static int pilotL_autoweap (lua_State *L)
 Gets if a pilot is using automatically set weapon sets.
static int pilotL_weapset (lua_State *L)
 Gets the weapset weapon of the pilot.
static int pilotL_weapsetList (lua_State *L)
 Get a list of all the outfits in a weapon set.
static int pilotL_weapsetType (lua_State *L)
 Sets the type of a weapon set for a pilot.
static int pilotL_weapsetAdd (lua_State *L)
 Adds an outfit to a pilot's weapon set.
static int pilotL_weapsetAddType (lua_State *L)
 Adds an outfit to a pilot's weapon set.
static int pilotL_weapsetRm (lua_State *L)
 Removes an outfit from a pilot's weapon set.
static int pilotL_weapsetCleanup (lua_State *L)
 Cleans up a weapon set. This removes all properties of the weapon set and resets it.
static int pilotL_weapsetHeat (lua_State *L)
 Gets heat information for a weapon set.
static int pilotL_weapsetSetInrange (lua_State *L)
 Sets whether a pilot's weapon set does inrange checks.
static int pilotL_weapsetAmmo (lua_State *L)
 Gets the ammo left of a weapon set.
static int pilotL_weapsetAuto (lua_State *L)
 Makes the pilot's weapons get automatically set.
static int pilotL_actives (lua_State *L)
 Gets the active outfits and their states of the pilot.
static int pilotL_outfitsList (lua_State *L)
 Gets the outfits of a pilot.
static int pilotL_outfits (lua_State *L)
 Gets a mapping of outfit slot IDs and outfits of a pilot.
static int pilotL_outfitsEquip (lua_State *L)
 Equips a pilot with a set of outfits.
static int pilotL_outfitGet (lua_State *L)
 Gets a pilot's outfit by ID.
static int pilotL_outfitToggle (lua_State *L)
 Toggles an outfit.
static int pilotL_outfitReady (lua_State *L)
 Sees if an outfit is ready to use.
static int pilotL_rename (lua_State *L)
 Changes the pilot's name.
static int pilotL_position (lua_State *L)
 Gets the pilot's position.
static int pilotL_velocity (lua_State *L)
 Gets the pilot's velocity.
static int pilotL_isStopped (lua_State *L)
 Checks to see if a pilot is stopped.
static int pilotL_dir (lua_State *L)
 Gets the pilot's direction.
static int pilotL_signature (lua_State *L)
 Gets the pilot's signature.
static int pilotL_temp (lua_State *L)
 Gets the temperature of a pilot.
static int pilotL_mass (lua_State *L)
 Gets the mass of a pilot.
static int pilotL_accel (lua_State *L)
 Gets the accel of a pilot.
static int pilotL_speed (lua_State *L)
 Gets the speed of a pilot.
static int pilotL_speed_max (lua_State *L)
 Gets the maximum speed of a pilot.
static int pilotL_turn (lua_State *L)
 Gets the turn of a pilot.
static int pilotL_faction (lua_State *L)
 Gets the pilot's faction.
static int pilotL_reputation (lua_State *L)
 Get the reputation the player has with the pilot's faction.
static int pilotL_areEnemies (lua_State *L)
 Checks to see if two pilots are enemies.
static int pilotL_areAllies (lua_State *L)
 Checks to see if two pilots are allies.
static int pilotL_spaceworthy (lua_State *L)
 Checks the pilot's spaceworthiness.
static int pilotL_setPosition (lua_State *L)
 Sets the pilot's position.
static int pilotL_setVelocity (lua_State *L)
 Sets the pilot's velocity.
static int pilotL_setDir (lua_State *L)
 Sets the pilot's direction.
static int pilotL_broadcast (lua_State *L)
 Makes the pilot broadcast a message.
static int pilotL_comm (lua_State *L)
 Sends a message to the target or player if no target is passed.
static int pilotL_setFaction (lua_State *L)
 Sets the pilot's faction.
static int pilotL_setHostile (lua_State *L)
 Controls the pilot's hostility towards the player.
static int pilotL_setFriendly (lua_State *L)
 Controls the pilot's friendliness towards the player.
static int pilotL_setInvincible (lua_State *L)
 Sets the pilot's invincibility status.
static int pilotL_setInvincPlayer (lua_State *L)
 Sets the pilot's invincibility status towards the player.
static int pilotL_setHide (lua_State *L)
 Sets the pilot's hide status.
static int pilotL_setInvisible (lua_State *L)
 Sets the pilot's invisibility status.
static int pilotL_setNoRender (lua_State *L)
 Sets the pilot's norender status.
static int pilotL_setVisplayer (lua_State *L)
 Marks the pilot as always visible for the player.
static int pilotL_setVisible (lua_State *L)
 Marks the pilot as always visible for other pilots.
static int pilotL_setHilight (lua_State *L)
 Makes pilot stand out on radar and the likes.
static int pilotL_setBribed (lua_State *L)
 Makes pilot act as if bribed by the player.
static int pilotL_getColour (lua_State *L)
 Gets the pilot's colour based on hostility or friendliness to the player.
static int pilotL_colourChar (lua_State *L)
 Gets the pilot's colour character based on hostility or friendliness to the player. For use with functions that print to the screen.
static int pilotL_getHostile (lua_State *L)
 Returns whether the pilot is hostile to the player.
static int pilotL_flags (lua_State *L)
 Gets the pilot's flags.
static int pilotL_hasIllegal (lua_State *L)
 Checks to see if the pilot has illegal stuff to a faction.
static int pilotL_setActiveBoard (lua_State *L)
 Allows the pilot to be boarded when not disabled.
static int pilotL_setNoDeath (lua_State *L)
 Makes it so the pilot never dies, stays at 1. armour.
static int pilotL_disabled (lua_State *L)
 Gets the disabled state of a pilot.
static int pilotL_disable (lua_State *L)
static int pilotL_setDisable (lua_State *L)
 Disables a pilot.
static int pilotL_cooldown (lua_State *L)
 Gets a pilot's cooldown state.
static int pilotL_setCooldown (lua_State *L)
 Starts or stops a pilot's cooldown mode.
static int pilotL_cooldownCycle (lua_State *L)
 Makes the pilot do an instant full cooldown cycle.
static int pilotL_setNoJump (lua_State *L)
 Enables or disables a pilot's hyperspace engine.
static int pilotL_setNoLand (lua_State *L)
 Enables or disables landing for a pilot.
static int pilotL_setNoClear (lua_State *L)
 Enables or disables making the the pilot exempt from pilot.clear().
static int pilotL_outfitAdd (lua_State *L)
 Adds an outfit to a pilot.
static int pilotL_outfitRm (lua_State *L)
 Removes an outfit from a pilot.
static int pilotL_outfitSlot (lua_State *L)
 Checks to see outfit a pilot has in a slot.
static int pilotL_outfitAddSlot (lua_State *L)
 Adds an outfit to a pilot by slot name.
static int pilotL_outfitRmSlot (lua_State *L)
 Removes an outfit from a pilot's named slot.
static int pilotL_outfitAddIntrinsic (lua_State *L)
 Adds an intrinsic outfit to the pilot.
static int pilotL_outfitRmIntrinsic (lua_State *L)
 Removes an intrinsic outfit from the pilot.
static int pilotL_getFuel (lua_State *L)
 Gets the amount of fuel the pilot has.
static int pilotL_setFuel (lua_State *L)
 Sets the fuel of a pilot.
static int pilotL_intrinsicReset (lua_State *L)
 Resets the intrinsic stats of a pilot.
static int pilotL_intrinsicSet (lua_State *L)
 Allows setting intrinsic stats of a pilot.
static int pilotL_intrinsicGet (lua_State *L)
 Allows getting an intrinsic stats of a pilot, or gets all of them if name is not specified.
static int pilotL_shippropReset (lua_State *L)
 Resets the ship property stats of a pilot.
static int pilotL_shippropSet (lua_State *L)
 Allows setting ship property stats of a pilot.
static int pilotL_shippropGet (lua_State *L)
 Allows getting an ship property stats of a pilot, or gets all of them if name is not specified.
static int pilotL_effectClear (lua_State *L)
 Clears the effect on a pilot.
static int pilotL_effectAdd (lua_State *L)
 Adds an effect to a pilot.
static int pilotL_effectRm (lua_State *L)
 Removes an effect from the pilot.
static int pilotL_effectHas (lua_State *L)
 Checks to see if a player has an instance of an effect active. Lua function parameter: Pilot p Pilot to check. Lua function parameter: string Name of the effect to check. Lua return parameter: boolean Whether or not the pilot has the effect active.
static int pilotL_effectGet (lua_State *L)
 Gets the effects on a pilot.
static int pilotL_ai (lua_State *L)
 Gets the pilot's AI.
static int pilotL_changeAI (lua_State *L)
 Changes the pilot's AI.
static int pilotL_setTemp (lua_State *L)
 Sets the temperature of a pilot.
static int pilotL_setHealth (lua_State *L)
 Sets the health of a pilot.
static int pilotL_setHealthAbs (lua_State *L)
 Sets the health of a pilot in absolute value.
static int pilotL_addHealth (lua_State *L)
 Adds health to a pilot.
static int pilotL_setEnergy (lua_State *L)
 Sets the energy of a pilot.
static int pilotL_addEnergy (lua_State *L)
 Adds (or subtracts) energy to a pilot.
static int pilotL_fillAmmo (lua_State *L)
 Fills up the pilot's ammo.
static int pilotL_setNoBoard (lua_State *L)
 Sets the ability to board the pilot.
static int pilotL_setNoDisable (lua_State *L)
 Sets the ability of the pilot to be disabled.
static int pilotL_setSpeedLimit (lua_State *L)
 Limits the speed of a pilot.
static int pilotL_getHealth (lua_State *L)
 Gets the pilot's health.
static int pilotL_getArmour (lua_State *L)
 Gets the pilot's armour.
static int pilotL_getShield (lua_State *L)
 Gets the pilot's shield.
static int pilotL_getStress (lua_State *L)
 Gets the pilot's stress.
static int pilotL_getEnergy (lua_State *L)
 Gets the pilot's energy.
static int pilotL_getLockon (lua_State *L)
 Gets the lockons on the pilot.
static int pilotL_getStats (lua_State *L)
 Gets stats of the pilot.
static int pilotL_getShipStat (lua_State *L)
 Gets a shipstat from a Pilot by name, or a table containing all the ship stats if not specified.
static int pilotL_getDetectedDistance (lua_State *L)
 Gets the distance that a pilot can be currently detect at.
static int pilotL_cargoFree (lua_State *L)
 Gets the free cargo space the pilot has.
static int pilotL_cargoHas (lua_State *L)
 Checks to see how many tonnes of a specific type of cargo the pilot has.
static int pilotL_cargoAdd (lua_State *L)
 Tries to add cargo to the pilot's ship.
static int pilotL_cargoRm (lua_State *L)
 Tries to remove cargo from the pilot's ship.
static int pilotL_cargoJet (lua_State *L)
 Tries to remove a cargo from a pilot's ship and jet it into space.
static int pilotL_cargoList (lua_State *L)
 Lists the cargo the pilot has.
static int pilotL_credits (lua_State *L)
 Handles the pilots credits.
static int pilotL_worth (lua_State *L)
 Gets the worth of a pilot (total value of ship and outfits).
static int pilotL_ship (lua_State *L)
 Gets the pilot's ship.
static int pilotL_points (lua_State *L)
 Gets the points the pilot costs.
static int pilotL_radius (lua_State *L)
 Gets the rough radius of the ship, useful for collision stuff.
static int pilotL_idle (lua_State *L)
 Checks to see if the pilot is idle.
static int pilotL_control (lua_State *L)
 Sets manual control of the pilot.
static int pilotL_memory (lua_State *L)
 Gets a pilots memory table.
static int pilotL_shipmemory (lua_State *L)
 Gets a pilots ship memory table.
static int pilotL_ainame (lua_State *L)
 Gets the name of the task the pilot is currently doing.
static int pilotL_task (lua_State *L)
 Gets the name and data of a pilot's current task.
static int pilotL_taskname (lua_State *L)
 Gets the name of the task the pilot is currently doing.
static int pilotL_taskstack (lua_State *L)
 Gets the name of all the pilot's current tasks (not subtasks).
static int pilotL_taskdata (lua_State *L)
 Gets the data of the task the pilot is currently doing.
static int pilotL_taskclear (lua_State *L)
 Clears all the tasks of the pilot.
static int pilotL_pushtask (lua_State *L)
 Pushes a new task to the pilot's AI.
static int pilotL_poptask (lua_State *L)
 Pops the current task from the pilot's AI.
static int pilotL_refuel (lua_State *L)
 Tries to refuel a pilot.
static int pilotL_moveto (lua_State *L)
 Makes the pilot move to a position.
static int pilotL_face (lua_State *L)
 Makes the pilot face a target.
static int pilotL_brake (lua_State *L)
 Makes the pilot brake.
static int pilotL_follow (lua_State *L)
 Makes the pilot follow another pilot.
static int pilotL_attack (lua_State *L)
 Makes the pilot attack another pilot.
static int pilotL_board (lua_State *L)
 Makes the pilot board another pilot.
static int pilotL_runaway (lua_State *L)
 Makes the pilot runaway from another pilot.
static int pilotL_gather (lua_State *L)
 Makes the pilot gather stuff.
static int pilotL_canHyperspace (lua_State *L)
 Checks to see if the pilot can currently hyperspace (as in has target jump and is in range).
static int pilotL_hyperspace (lua_State *L)
 Tells the pilot to hyperspace.
static int pilotL_stealth (lua_State *L)
 Tells the pilot to try to stealth.
static int pilotL_tryStealth (lua_State *L)
 Tries to make the pilot stealth.
static int pilotL_destealth (lua_State *L)
 Tries to make the pilot stealth.
static int pilotL_land (lua_State *L)
 Tells the pilot to land.
static int pilotL_hailPlayer (lua_State *L)
 Marks the pilot as hailing the player.
static int pilotL_msg (lua_State *L)
 Sends a message to another pilot.
static int pilotL_mothership (lua_State *L)
 Gets a pilots mothership (only exists for deployed pilots). Guaranteed to exist or will be nil.
static int pilotL_leader (lua_State *L)
 Gets a pilots leader. Guaranteed to exist or will be nil.
static int pilotL_setLeader (lua_State *L)
 Set a pilots leader.
static int pilotL_followers (lua_State *L)
 Get all of a pilots followers.
static int pilotL_hookClear (lua_State *L)
 Clears the pilot's hooks.
static int pilotL_choosePoint (lua_State *L)
 Returns a suitable jumpin spot for a given pilot. Lua usage parameter: point = pilot.choosePoint( f, i, g )
static int pilotL_collisionTest (lua_State *L)
 Tests to see if two ships collide.
static int pilotL_damage (lua_State *L)
 Damages a pilot.
static int pilotL_kill (lua_State *L)
 Kills a pilot.
static int pilotL_knockback (lua_State *L)
 Knocks back a pilot. It can either accept two pilots, or a pilot and an element represented by mass, velocity, and position.
static int pilotL_distress (lua_State *L)
 Sends a distress single from the pilot.
static int pilotL_calcStats (lua_State *L)
 Forces a recomputation of the pilots' stats.
static int pilotL_shipvarPeek (lua_State *L)
 Peeks at a ship variable.
static int pilotL_shipvarPush (lua_State *L)
 Pushes a ship variable.
static int pilotL_shipvarPop (lua_State *L)
 Pops a ship variable.
static int pilotL_renderComm (lua_State *L)
 Renders the pilot communication image.
static int pilotL_render (lua_State *L)
 Renders the pilot to a canvas.
static int pilotL_renderTo (lua_State *L)
 Renders the pilot to a canvas.
int nlua_loadPilot (nlua_env env)
 Loads the pilot library.
LuaPilot lua_topilot (lua_State *L, int ind)
 Lua bindings to interact with pilots.
LuaPilot luaL_checkpilot (lua_State *L, int ind)
 Gets pilot at index or raises error if there is no pilot at index.
PilotluaL_validpilot (lua_State *L, int ind)
 Makes sure the pilot is valid or raises a Lua error.
LuaPilot * lua_pushpilot (lua_State *L, LuaPilot pilot)
 Pushes a pilot on the stack.
int lua_ispilot (lua_State *L, int ind)
 Checks to see if ind is a pilot.
static void clearSelect (Pilot *const *pilot_stack, int f)
static void toggleSpawn (int f, int b)
static int getFriendOrFoeTest (const Pilot *p, const Pilot *plt, int friend, double dd, int inrange, int dis, int fighters, const vec2 *v, LuaFaction lf)
static int weapsetItem (lua_State *L, int *k, Pilot *p, const PilotOutfitSlot *slot, const Pilot *target)
 Sets up an item in a weapon set.
static int outfitToggle (lua_State *L, Pilot *p, int id, int activate)
static int pilotL_cargoRmHelper (lua_State *L, int jet)
static const CollPolyViewgetCollPoly (const Pilot *p)

Variables

Pilotcur_pilot
static const luaL_Reg pilotL_methods []
static const struct pL_flag pL_flags []

Detailed Description

Handles the Lua pilot bindings.

These bindings control the spobs and systems.

Definition in file nlua_pilot.c.

Macro Definition Documentation

◆ PUSH_DOUBLE

#define PUSH_DOUBLE ( L,
name,
value )
Value:
lua_pushstring( L, name ); \
lua_pushnumber( L, value ); \
lua_rawset( L, -3 )

Definition at line 4955 of file nlua_pilot.c.

◆ PUSH_INT

#define PUSH_INT ( L,
name,
value )
Value:
lua_pushstring( L, name ); \
lua_pushinteger( L, value ); \
lua_rawset( L, -3 )

Definition at line 4959 of file nlua_pilot.c.

Function Documentation

◆ clearSelect()

void clearSelect ( Pilot *const * pilot_stack,
int f )
static

Definition at line 904 of file nlua_pilot.c.

◆ getCollPoly()

const CollPolyView * getCollPoly ( const Pilot * p)
static

Definition at line 6601 of file nlua_pilot.c.

◆ getFriendOrFoeTest()

int getFriendOrFoeTest ( const Pilot * p,
const Pilot * plt,
int friend,
double dd,
int inrange,
int dis,
int fighters,
const vec2 * v,
LuaFaction lf )
static

Definition at line 1102 of file nlua_pilot.c.

◆ lua_ispilot()

int lua_ispilot ( lua_State * L,
int ind )

Checks to see if ind is a pilot.

Parameters
LLua state to check.
indIndex position to check.
Returns
1 if ind is a pilot.

Definition at line 591 of file nlua_pilot.c.

◆ lua_pushpilot()

LuaPilot * lua_pushpilot ( lua_State * L,
LuaPilot pilot )

Pushes a pilot on the stack.

Parameters
LLua state to push pilot into.
pilotPilot to push.
Returns
Newly pushed pilot.

Definition at line 576 of file nlua_pilot.c.

◆ lua_topilot()

LuaPilot lua_topilot ( lua_State * L,
int ind )

Lua bindings to interact with pilots.

This will allow you to create and manipulate pilots in-game.

An example would be:

p = pilot.add( "Llama", "Miner" ) -- Create a Miner Llama
p:setFriendly() -- Make it friendly

Lua module: pilot

Gets pilot at index.

Parameters
LLua state to get pilot from.
indIndex position to find the pilot.
Returns
Pilot found at the index in the state.

Definition at line 535 of file nlua_pilot.c.

◆ luaL_checkpilot()

LuaPilot luaL_checkpilot ( lua_State * L,
int ind )

Gets pilot at index or raises error if there is no pilot at index.

Parameters
LLua state to get pilot from.
indIndex position to find pilot.
Returns
Pilot found at the index in the state.

Definition at line 546 of file nlua_pilot.c.

◆ luaL_checkslot()

PilotOutfitSlot * luaL_checkslot ( lua_State * L,
Pilot * p,
int idx )
static

Definition at line 2025 of file nlua_pilot.c.

◆ luaL_checkweapset()

int luaL_checkweapset ( lua_State * L,
int idx )
static

Definition at line 2017 of file nlua_pilot.c.

◆ luaL_validpilot()

Pilot * luaL_validpilot ( lua_State * L,
int ind )

Makes sure the pilot is valid or raises a Lua error.

Parameters
LState currently running.
indIndex of the pilot to validate.
Returns
The pilot (doesn't return if fails - raises Lua error ).

Definition at line 560 of file nlua_pilot.c.

◆ nlua_loadPilot()

int nlua_loadPilot ( nlua_env env)

Loads the pilot library.

Parameters
envEnvironment to load library into.
Returns
0 on success.

Definition at line 481 of file nlua_pilot.c.

◆ outfit_compareActive()

int outfit_compareActive ( const void * slot1,
const void * slot2 )
static

qsort compare function for active outfits.

Definition at line 2495 of file nlua_pilot.c.

◆ outfitToggle()

int outfitToggle ( lua_State * L,
Pilot * p,
int id,
int activate )
static

Definition at line 2690 of file nlua_pilot.c.

◆ pilot_outfitAddSlot()

int pilot_outfitAddSlot ( Pilot * p,
const Outfit * o,
PilotOutfitSlot * s,
int bypass_cpu,
int bypass_slot )
static

Adds an outfit to a specific slot.

Returns
0 on failure to add, -1 on error to add, and 1 if added.

Definition at line 3686 of file nlua_pilot.c.

◆ pilotL_accel()

int pilotL_accel ( lua_State * L)
static

Gets the accel of a pilot.

Lua function parameter: Pilot p Pilot to get accel of. Lua return parameter: number The pilot's current accel.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: accel

Definition at line 2920 of file nlua_pilot.c.

◆ pilotL_actives()

int pilotL_actives ( lua_State * L)
static

Gets the active outfits and their states of the pilot.

The active outfits have the following structure:

  • outfit: The outfit.
  • type: Type of the outfit.
  • active: Whether or not the outfit is active at the current time.
  • heat: The heat of the outfit's slot. A value between 0 and 1, where 0 is fully overheated, and 1 is normal.
  • weapset: The first weapon set that the outfit appears in, if any.
  • state: State of the outfit, which can be one of { "off", "warmup", "on", "cooldown" }.
  • duration: Set only if state is "on". Indicates duration value (0 = just finished, 1 = just on).
  • cooldown: Set only if state is "cooldown". Indicates cooldown value (0 = just ending, 1 = just started cooling down).

An example would be:

act_outfits = p:actives()
print( "Weapnset Name: " .. ws_name )
for i, o in ipairs(act_outfits) do
print( "Name: " .. o.name )
print( "State: " .. o.state )
end

Lua usage parameter: act_outfits = p:actives() – Gets the table of active outfits

Lua function parameter: Pilot p Pilot to get active outfits of. Lua function parameter:[opt=false] boolean sort Whether or not to sort the outfits. Lua return parameter: table The table with each active outfit's information.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: actives

Definition at line 2350 of file nlua_pilot.c.

◆ pilotL_add()

int pilotL_add ( lua_State * L)
static

Adds a ship with an AI and faction to the system (instead of a predefined fleet).

Lua usage parameter: p = pilot.add( "Empire Shark", "Empire" ) – Creates a standard Empire Shark. Lua usage parameter: p = pilot.add( "Pirate Hyena", "Pirate", _("Blackbeard") ) – Just adds the pilot (will jump in or take off). Lua usage parameter: p = pilot.add( "Llama", "Trader", nil, _("Trader Llama"), {ai="dummy"} ) – Overrides AI with dummy ai. Lua usage parameter: p = pilot.add( "Gawain", "Civilian", vec2.new( 1000, 200 ) ) – Pilot won't jump in, will just appear. Lua usage parameter: p = pilot.add( "Empire Pacifier", "Empire", system.get("Goddard") ) – Have the pilot jump in from the system. Lua usage parameter: p = pilot.add( "Goddard", "Goddard", spob.get("Zhiru") , _("Goddard Goddard") ) – Have the pilot take off from a spob.

How param works (by type of value passed):

  • nil: spawns pilot randomly entering from jump points with presence of their faction or taking off from non-hostile spobs
  • spob: pilot takes off from the spob
  • system: jumps pilot in from the system
  • vec2: pilot is created at the position (no jump/takeoff)
  • true: Acts like nil, but does not avoid jump points with no presence

    Lua function parameter: Ship|string shipname Name of the ship to add. Lua function parameter: Faction |stringfaction Faction to give the pilot. Lua function parameter: System|Spob|Vec2 param Position to create pilot at, if it's a system it'll try to jump in from that system, if it's a spob it'll try to take off from it. Lua function parameter:[opt] string pilotname Name to give the pilot. Defaults to shipname. Lua function parameter:[opt] table parameters Table of extra keyword arguments. Supported arguments: "ai" (string): AI to give the pilot. Defaults to the faction's AI. "naked" (boolean): Whether or not to have the pilot spawn without outfits. Defaults to false. "stealth" (boolean): Whether or not to have the pilot spawn in stealth mode. Defaults to false. Lua return parameter: Pilot The created pilot.

    Parameters
    LLua State
    Returns
    Number of variables on the Lua State stack.

    Lua function: add

Definition at line 683 of file nlua_pilot.c.

◆ pilotL_addEnergy()

int pilotL_addEnergy ( lua_State * L)
static

Adds (or subtracts) energy to a pilot.

Lua function parameter: Pilot p Pilot to set energy of. Lua function parameter: number energy Energy value to add.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: addEnergy

Definition at line 4697 of file nlua_pilot.c.

◆ pilotL_addHealth()

int pilotL_addHealth ( lua_State * L)
static

Adds health to a pilot.

Does not revive dead pilots, use setHealth for that.

Lua function parameter: Pilot p Pilot to add health to. Lua function parameter:[opt=0.] number armour Armour to add. Lua function parameter:[opt=0.] number shield Shield to add.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: addHealth

Definition at line 4642 of file nlua_pilot.c.

◆ pilotL_ai()

int pilotL_ai ( lua_State * L)
static

Gets the pilot's AI.

Lua function parameter: Pilot p Pilot to get AI of. Lua return parameter: string Name of the AI being used.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: ai

Definition at line 4447 of file nlua_pilot.c.

◆ pilotL_ainame()

int pilotL_ainame ( lua_State * L)
static

Gets the name of the task the pilot is currently doing.

Lua function parameter: Pilot p Pilot to get task name of. Lua return parameter: string Name of the task.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: ainame

Definition at line 5643 of file nlua_pilot.c.

◆ pilotL_areAllies()

int pilotL_areAllies ( lua_State * L)
static

Checks to see if two pilots are allies.

Lua function parameter: Pilot p Pilot to check. Lua function parameter: Pilot t Target pilot to check. Lua return parameter: boolean true if both p and t are allies, false otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: areAllies

Definition at line 3026 of file nlua_pilot.c.

◆ pilotL_areEnemies()

int pilotL_areEnemies ( lua_State * L)
static

Checks to see if two pilots are enemies.

Lua function parameter: Pilot p Pilot to check. Lua function parameter: Pilot t Target pilot to check. Lua return parameter: boolean true if both p and t are enemies, false otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: areEnemies

Definition at line 3010 of file nlua_pilot.c.

◆ pilotL_attack()

int pilotL_attack ( lua_State * L)
static

Makes the pilot attack another pilot.

Pilot must be under manual control for this to work.

Lua usage parameter: p:attack( another_pilot ) – Attack another pilot Lua usage parameter: p:attack() – Attack nearest pilot.

Lua function parameter: Pilot p Pilot to tell to attack another pilot. Lua function parameter:[opt] Pilot pt Target pilot to attack (or nil to attack nearest enemy). See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: attack

Definition at line 6016 of file nlua_pilot.c.

◆ pilotL_autoweap()

int pilotL_autoweap ( lua_State * L)
static

Gets if a pilot is using automatically set weapon sets.

Lua function parameter: Pilot p Pilot to get whether or not is using automatic weapon sets. Lua return parameter: boolean Whether or not the pilot is using automatic weapon sets.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: autoweap

Definition at line 1929 of file nlua_pilot.c.

◆ pilotL_board()

int pilotL_board ( lua_State * L)
static

Makes the pilot board another pilot.

Pilot must be under manual control for this to work.

Lua usage parameter: p:board( another_pilot ) – Attack another pilot

Lua function parameter: Pilot p Pilot to tell to board another pilot. Lua function parameter: Pilot pt Target pilot to board See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: board

Definition at line 6053 of file nlua_pilot.c.

◆ pilotL_brake()

int pilotL_brake ( lua_State * L)
static

Makes the pilot brake.

Pilot must be under manual control for this to work.

Lua function parameter: Pilot p Pilot to tell to brake. See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: brake

Definition at line 5959 of file nlua_pilot.c.

◆ pilotL_broadcast()

int pilotL_broadcast ( lua_State * L)
static

Makes the pilot broadcast a message.

Lua usage parameter: p:broadcast(_("Mayday! Requesting assistance!")) Lua usage parameter: p:broadcast(_("Help!"), true ) – Will ignore interference Lua usage parameter: pilot.broadcast( _("Message Buoy"), _("Important annauncement") ) – Messages player ignoring interference

Lua function parameter: Pilot|string p Pilot to broadcast the message, or string to use as a fictional pilot name. In the case of a string, interference is always ignored, and instead of the ignore_int parameter, a colour character such as 'F' or 'H' can be optionally passed. Lua function parameter: string msg Message to broadcast. Lua function parameter:[opt=false] boolean ignore_int Whether or not it should ignore interference.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: broadcast

Definition at line 3144 of file nlua_pilot.c.

◆ pilotL_calcStats()

int pilotL_calcStats ( lua_State * L)
static

Forces a recomputation of the pilots' stats.

Lua function parameter: Pilot p Pilot to recalculate stats of.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: calcStats

Definition at line 6850 of file nlua_pilot.c.

◆ pilotL_canHyperspace()

int pilotL_canHyperspace ( lua_State * L)
static

Checks to see if the pilot can currently hyperspace (as in has target jump and is in range).

Lua function parameter: Pilot p Pilot to check if they can hyperspace. Lua return parameter: boolean Whether or not the pilot can hyperspace.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: canHyperspace

Definition at line 6153 of file nlua_pilot.c.

◆ pilotL_canSpawn()

int pilotL_canSpawn ( lua_State * L)
static

Returns if pilots can can spawn naturally in the current system.

Lua return parameter: boolean The current spawn state.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: canSpawn

Definition at line 967 of file nlua_pilot.c.

◆ pilotL_cargoAdd()

int pilotL_cargoAdd ( lua_State * L)
static

Tries to add cargo to the pilot's ship.

Lua usage parameter: n = pilot.cargoAdd( player.pilot(), "Food", 20 )

Lua function parameter: Pilot p The pilot to add cargo to. Lua function parameter: Commodity|string cargo Type of cargo to add, either as a Commodity object or as the raw (untranslated) name of a commodity. Lua function parameter: number quantity Quantity of cargo to add. Lua return parameter: number The quantity of cargo added.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cargoAdd

Definition at line 5123 of file nlua_pilot.c.

◆ pilotL_cargoFree()

int pilotL_cargoFree ( lua_State * L)
static

Gets the free cargo space the pilot has.

Lua function parameter: Pilot p The pilot to get the free cargo space of. Lua return parameter: number The free cargo space in tonnes of the player.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cargoFree

Definition at line 5083 of file nlua_pilot.c.

◆ pilotL_cargoHas()

int pilotL_cargoHas ( lua_State * L)
static

Checks to see how many tonnes of a specific type of cargo the pilot has.

Lua function parameter: Pilot p The pilot to get the cargo count of. Lua function parameter: Commodity|string cargo Type of cargo to check, either as a Commodity object or as the raw (untranslated) name of a commodity. Lua return parameter: number The amount of cargo the player has.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cargoHas

Definition at line 5101 of file nlua_pilot.c.

◆ pilotL_cargoJet()

int pilotL_cargoJet ( lua_State * L)
static

Tries to remove a cargo from a pilot's ship and jet it into space.

Lua function parameter: Pilot p The pilot to remove cargo from. Lua function parameter: Commodity|string cargo Type of cargo to remove, either as a Commodity object or as the raw (untranslated) name of a commodity. You can also pass the special value "all" to remove all cargo from the pilot, except for mission cargo. Lua function parameter: number quantity Quantity of the cargo to remove. Lua return parameter: number The number of cargo removed.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cargoJet

Definition at line 5211 of file nlua_pilot.c.

◆ pilotL_cargoList()

int pilotL_cargoList ( lua_State * L)
static

Lists the cargo the pilot has.

The list has the following members:

  • name: raw (untranslated) name of the cargo (equivalent to the output of commodity.nameRaw()).
  • c: the cargo commodity.
  • q: quantity of the cargo.
  • m: true if cargo is for a mission.

Lua usage parameter: for i, v in ipairs(pilot.cargoList(player.pilot())) do print( string.format("%s: %d", v.name, v.q ) ) end

Lua function parameter: Pilot p Pilot to list cargo of. Lua return parameter: table An ordered list with the names of the cargo the pilot has.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cargoList

Definition at line 5235 of file nlua_pilot.c.

◆ pilotL_cargoRm()

int pilotL_cargoRm ( lua_State * L)
static

Tries to remove cargo from the pilot's ship.

Lua usage parameter: n = pilot.cargoRm(player.pilot(), "Food", 20) Lua usage parameter: n = pilot.cargoRm(player.pilot(), "all") – Removes all cargo from the player

Lua function parameter: Pilot p The pilot to remove cargo from. Lua function parameter: Commodity|string cargo Type of cargo to remove, either as a Commodity object or as the raw (untranslated) name of a commodity. You can also pass the special value "all" to remove all cargo from the pilot, except for mission cargo. Lua function parameter: number quantity Quantity of the cargo to remove. Lua return parameter: number The number of cargo removed.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cargoRm

Definition at line 5194 of file nlua_pilot.c.

◆ pilotL_cargoRmHelper()

int pilotL_cargoRmHelper ( lua_State * L,
int jet )
static

Definition at line 5140 of file nlua_pilot.c.

◆ pilotL_changeAI()

int pilotL_changeAI ( lua_State * L)
static

Changes the pilot's AI.

Lua usage parameter: p:changeAI( "empire" ) – set the pilot to use the Empire AI

Lua function parameter: Pilot p Pilot to change AI of. Lua function parameter: string newai Name of Ai to use.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: changeAI

Definition at line 4465 of file nlua_pilot.c.

◆ pilotL_choosePoint()

int pilotL_choosePoint ( lua_State * L)
static

Returns a suitable jumpin spot for a given pilot. Lua usage parameter: point = pilot.choosePoint( f, i, g )

Lua function parameter: Faction f Faction the pilot will belong to. Lua function parameter:[opt=false] boolean i Whether to ignore rules. Lua function parameter:[opt=false] boolean g Whether to behave as guerilla (spawn in deep space) Lua return parameter: Spob|Vec2|Jump A randomly chosen suitable spawn point.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: choosePoint

Definition at line 618 of file nlua_pilot.c.

◆ pilotL_clear()

int pilotL_clear ( lua_State * L)
static

Clears the current system of pilots. Used for epic battles and such.

Be careful with this command especially in big systems. It will most likely cause issues if multiple missions are in the same system.

Note
Clears all global pilot hooks too.

Lua usage parameter: pilot.clear()

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: clear

Definition at line 953 of file nlua_pilot.c.

◆ pilotL_clearSelect()

int pilotL_clearSelect ( lua_State * L)
static

Removes all pilots belonging to a faction from the system.

Lua function parameter: Faction|table fac Faction name/object or table of faction name/objects to selectively clear.

Lua usage parameter: pilot.clearSelect("Empire")

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: clearSelect

Definition at line 926 of file nlua_pilot.c.

◆ pilotL_clone()

int pilotL_clone ( lua_State * L)
static

Clones a pilot. It will share nearly all properties including outfits.

Lua function parameter: Pilot p Pilot to clone. Lua return parameter: Pilot A new clone of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: clone

Definition at line 834 of file nlua_pilot.c.

◆ pilotL_collisionTest()

int pilotL_collisionTest ( lua_State * L)
static

Tests to see if two ships collide.

Lua function parameter: Pilot p First pilot to check. Lua function parameter: Pilot|Asteroid t Second object to check. Lua return parameter: Vec2|nil nil if no collision, or Vec2 with collision point if collided.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: collisionTest

Definition at line 6614 of file nlua_pilot.c.

◆ pilotL_colourChar()

int pilotL_colourChar ( lua_State * L)
static

Gets the pilot's colour character based on hostility or friendliness to the player. For use with functions that print to the screen.

Lua function parameter: Pilot p Pilot to get the colour of. Lua return parameter: string Character representing the pilot's colour for use with specila printing characters.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: colour

Definition at line 5325 of file nlua_pilot.c.

◆ pilotL_comm()

int pilotL_comm ( lua_State * L)
static

Sends a message to the target or player if no target is passed.

Lua usage parameter: p:comm( _("How are you doing?") ) – Messages the player Lua usage parameter: p:comm( _("You got this?"), true ) – Messages the player ignoring interference Lua usage parameter: p:comm( target, _("Heya!") ) – Messages target Lua usage parameter: p:comm( target, _("Got this?"), true ) – Messages target ignoring interference Lua usage parameter: pilot.comm( _("Message Buoy"), _("Important information just for you!") ) – Messages player ignoring interference

Lua function parameter: Pilot|string p Pilot to message the player, or string to use as a fictional pilot name. In the case of a string, interference is always ignored, and instead of ignore_int, a colour character such as 'F' or 'H' can be passed. Lua function parameter: Pilot target Target to send message to. Lua function parameter: string msg Message to send. Lua function parameter:[opt=false] boolean|colour param1 Whether or not it should ignore interference in the case a pilot is being used, otherwise it is a colour string such as 'N' that can be used to colour the text.. Lua function parameter:[opt=false] boolean raw Whether or not to just display the raw text without quotation marks instead of a "message".

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: comm

Definition at line 3193 of file nlua_pilot.c.

◆ pilotL_control()

int pilotL_control ( lua_State * L)
static

Sets manual control of the pilot.

Note that this will reset the pilot's current task when the state changes. In the case of the player, it will also clear autonav.

Lua usage parameter: p:control() – Same as p:control(true), enables manual control of the pilot Lua usage parameter: p:control(false) – Restarts AI control of the pilot Lua usage parameter: p:control( true, true ) – Enables manual control of the pilot and resets tasks.

Lua function parameter: Pilot p Pilot to change manual control settings. Lua function parameter:[opt=true] boolean enable If true or nil enables pilot manual control, otherwise enables automatic AI. Lua function parameter:[opt=true if changing modes] boolean Whether or not to clear the tasks for the pilot. Defaults to true when changing from manual to normal mode or viceversa. See also: moveto See also: brake See also: follow See also: attack See also: runaway See also: hyperspace See also: land

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: control

Definition at line 5554 of file nlua_pilot.c.

◆ pilotL_cooldown()

int pilotL_cooldown ( lua_State * L)
static

Gets a pilot's cooldown state.

Lua usage parameter: cooldown, braking = p:cooldown()

Lua function parameter: Pilot p Pilot to check the cooldown status of. Lua return parameter: boolean Cooldown status. Lua return parameter: boolean Cooldown braking status.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cooldown

Definition at line 3585 of file nlua_pilot.c.

◆ pilotL_cooldownCycle()

int pilotL_cooldownCycle ( lua_State * L)
static

Makes the pilot do an instant full cooldown cycle.

Lua function parameter: Pilot p Pilot to perform cycle.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: cooldownCycle

Definition at line 3629 of file nlua_pilot.c.

◆ pilotL_credits()

int pilotL_credits ( lua_State * L)
static

Handles the pilots credits.

Lua function parameter: Pilot p Pilot to manipulate credits of. Lua function parameter:[opt=0] number cred Credits to give to the pilot. Lua return parameter: number The credits the pilot has.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: credits

Definition at line 5274 of file nlua_pilot.c.

◆ pilotL_damage()

int pilotL_damage ( lua_State * L)
static

Damages a pilot.

Lua function parameter: Pilot p Pilot being damaged. Lua function parameter: number dmg Damage being done. Lua function parameter:[opt=0.] number disable Disable being done. Lua function parameter:[opt=0.] number penetration Penetration (in %). Lua function parameter:[opt="raw"] string type Damage type being done. Lua function parameter:[opt=nil] Pilot shooter Pilot doing the damage. Lua return parameter: number Amount of damage done.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: damage

Definition at line 6670 of file nlua_pilot.c.

◆ pilotL_destealth()

int pilotL_destealth ( lua_State * L)
static

Tries to make the pilot stealth.

Lua function parameter: Pilot p Pilot to try to make stealth. Lua return parameter: boolean Whether or not the pilot was able to stealth.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: destealth

Definition at line 6262 of file nlua_pilot.c.

◆ pilotL_dir()

int pilotL_dir ( lua_State * L)
static

Gets the pilot's direction.

Lua usage parameter: d = p:dir()

Lua function parameter: Pilot p Pilot to get the direction of. Lua return parameter: number The pilot's current direction as a number (in radians).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: dir

Definition at line 2874 of file nlua_pilot.c.

◆ pilotL_disable()

int pilotL_disable ( lua_State * L)
static

Definition at line 3540 of file nlua_pilot.c.

◆ pilotL_disabled()

int pilotL_disabled ( lua_State * L)
static

Gets the disabled state of a pilot.

Lua function parameter: Pilot p Pilot to get disabled state of. Lua return parameter: boolean Whether or not the pilot is disabled.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: disabled

Definition at line 3518 of file nlua_pilot.c.

◆ pilotL_distress()

int pilotL_distress ( lua_State * L)
static

Sends a distress single from the pilot.

Does not cause a faction hit.

Lua function parameter: Pilot p Pilot to send a distress signal. Lua function parameter: Pilot attacker Pilot to be distressing about.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: distress

Definition at line 6803 of file nlua_pilot.c.

◆ pilotL_effectAdd()

int pilotL_effectAdd ( lua_State * L)
static

Adds an effect to a pilot.

Lua function parameter: Pilot p Pilot to add effect to. Lua function parameter: string name Name of the effect to add. Lua function parameter:[opt=-1] duration Duration of the effect or set to negative to be default. Lua function parameter:[opt=1] scale Scaling factor. Lua return parameter: boolean Whether or not the effect was successfully added.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: effectAdd

Definition at line 4327 of file nlua_pilot.c.

◆ pilotL_effectClear()

int pilotL_effectClear ( lua_State * L)
static

Clears the effect on a pilot.

Lua function parameter: Pilot p Pilot to clear effects of. Lua function parameter: boolean keepdebuffs Whether or not to keep debuffs. Lua function parameter: boolean keepbuffs Whether or not to keep buffs. Lua function parameter: boolean keepothers Whether or not to keep others.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: effectClear

Definition at line 4301 of file nlua_pilot.c.

◆ pilotL_effectGet()

int pilotL_effectGet ( lua_State * L)
static

Gets the effects on a pilot.

Lua function parameter: Pilot p Pilot to get effects of. Lua return parameter: table Table of effects which are treated as tables with "name" and "timer" elements.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: effects

Definition at line 4402 of file nlua_pilot.c.

◆ pilotL_effectHas()

int pilotL_effectHas ( lua_State * L)
static

Checks to see if a player has an instance of an effect active. Lua function parameter: Pilot p Pilot to check. Lua function parameter: string Name of the effect to check. Lua return parameter: boolean Whether or not the pilot has the effect active.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: effectHas

Definition at line 4379 of file nlua_pilot.c.

◆ pilotL_effectRm()

int pilotL_effectRm ( lua_State * L)
static

Removes an effect from the pilot.

Lua function parameter: Pilot p Pilot to remove effect from. Lua function parameter: string|integer name Name of the effect to add or index in the case of being a number. Lua function parameter: boolean all Remove all instances of the effect or only the most first instance. Only valid in the case the name is specified as a string.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: effectRm

Definition at line 4353 of file nlua_pilot.c.

◆ pilotL_eq()

int pilotL_eq ( lua_State * L)
static

Checks to see if pilot and p are the same.

Lua usage parameter: if p == p2 then – Pilot 'p' and 'p2' match.

Lua function parameter: Pilot p Pilot to compare. Lua function parameter: Pilot comp Pilot to compare against. Lua return parameter: boolean true if they are the same.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __eq

Definition at line 1399 of file nlua_pilot.c.

◆ pilotL_exists()

int pilotL_exists ( lua_State * L)
static

Checks to see if pilot is still in the system and alive.

Pilots cease to exist if they die or jump out.

Lua usage parameter: if p:exists() then – Pilot still exists

Lua function parameter: Pilot p Pilot to check to see if is still exists. Lua return parameter: boolean true if pilot is still exists.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: exists

Definition at line 1472 of file nlua_pilot.c.

◆ pilotL_explode()

int pilotL_explode ( lua_State * L)
static

Removes a pilot as if it exploded.

Note that this triggers the exploded hook which can cause the explosion to fail unlike pilot.rm.

Lua usage parameter: p:exploded() – pilot will be destroyed

Lua function parameter: Pilot p Pilot to remove. Lua return parameter: boolean true if exploded succeeded, false otherwise (such as when stopped by a hook).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: explode

Definition at line 881 of file nlua_pilot.c.

◆ pilotL_face()

int pilotL_face ( lua_State * L)
static

Makes the pilot face a target.

Lua usage parameter: p:face( enemy_pilot ) – Face enemy pilot Lua usage parameter: p:face( vec2.new( 0, 0 ) ) – Face origin Lua usage parameter: p:face( enemy_pilot, true ) – Task lasts until the enemy pilot is faced

Lua function parameter: Pilot p Pilot to add task to. Lua function parameter: Vec2|Pilot target Target to face. Lua function parameter:[opt=false] boolean towards Makes the task end when the target is faced (otherwise it's an enduring state).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: face

Definition at line 5918 of file nlua_pilot.c.

◆ pilotL_faction()

int pilotL_faction ( lua_State * L)
static

Gets the pilot's faction.

Lua usage parameter: f = p:faction()

Lua function parameter: Pilot p Pilot to get the faction of. Lua return parameter: Faction The faction of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: faction

Definition at line 2981 of file nlua_pilot.c.

◆ pilotL_fillAmmo()

int pilotL_fillAmmo ( lua_State * L)
static

Fills up the pilot's ammo.

Lua function parameter: Pilot p Pilot to fill ammo.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: fillAmmo

Definition at line 4712 of file nlua_pilot.c.

◆ pilotL_flags()

int pilotL_flags ( lua_State * L)
static

Gets the pilot's flags.

Valid flags are:

  • hailing: pilot is hailing the player.
  • boardable: pilot is boardable while active.
  • nojump: pilot cannot jump.
  • noland: pilot cannot land.
  • nodeath: pilot cannot die.
  • nodisable: pilot cannot be disabled.
  • escort: pilot is an escort.
  • visible: pilot is always visible.
  • visplayer: pilot is always visible to the player.
  • hilight: pilot is hilighted on the map.
  • stealth: pilot is in stealth mode.
  • invisible: pilot is not displayed.
  • invincible: pilot cannot be hit.
  • invinc_player: pilot cannot be hit by the player.
  • friendly: pilot is friendly toward the player.
  • hostile: pilot is hostile toward the player.
  • refueling: pilot is refueling another pilot.
  • disabled: pilot is disabled.
  • landing: pilot is currently landing.
  • takingoff: pilot is currently taking off.
  • manualcontrol: pilot is under manual control.
  • combat: pilot is engaged in combat.
  • carried: pilot came from a fighter bay.

Lua function parameter: Pilot p Pilot to get flags of. Lua function parameter:[opt] string name If provided, return only the individual flag. Lua return parameter: table Table with flag names an index, boolean as value.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: flags

Definition at line 5423 of file nlua_pilot.c.

◆ pilotL_follow()

int pilotL_follow ( lua_State * L)
static

Makes the pilot follow another pilot.

Pilot must be under manual control for this to work.

Lua function parameter: Pilot p Pilot to tell to follow another pilot. Lua function parameter: Pilot pt Target pilot to follow. Lua function parameter:[opt=false] boolean accurate If true, use a PD controller which parameters can be defined using the pilot's memory. See also: control See also: memory

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: follow

Definition at line 5979 of file nlua_pilot.c.

◆ pilotL_followers()

int pilotL_followers ( lua_State * L)
static

Get all of a pilots followers.

Lua function parameter: Pilot p Pilot to get the followers of. Lua function parameter: boolean hidefighters Whether or not to ignore deployed fighters. Lua return parameter: {Pilot,...} Table of followers.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: followers

Definition at line 6561 of file nlua_pilot.c.

◆ pilotL_gather()

int pilotL_gather ( lua_State * L)
static

Makes the pilot gather stuff.

Lua usage parameter: p:gather( ) – Try to gather stuff See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: gather

Definition at line 6137 of file nlua_pilot.c.

◆ pilotL_getAllies()

int pilotL_getAllies ( lua_State * L)
static

Gets friendly pilots to a pilot (or faction) within a certain distance.

Lua usage parameter: p:getAllies( 5000 ) – get allies within 5000 Lua usage parameter: pilot.getAllies( faction.get("Pirate"), 5000, vec2.new(0,0) ) – Got allies of "Pirate" faction 5000 units from origin

Lua function parameter: Pilot|faction pilot Pilot or to get allies of. Lua function parameter:[opt=infinity] number dist Distance to look for allies. Lua function parameter:[opt=pilot.pos] Vec2 pos Position to check from. Lua function parameter:[opt=false] boolean ignore_range Whether or not to only check for pilots in range (only in the case of pilot, not faction) Lua function parameter:[opt=false] boolean disabled Whether or not to count disabled pilots. Lua function parameter:[opt=false] boolean fighters Whether or not to count deployed fighters. Lua return parameter: {Pilot,...} A table containing the pilots.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getAllies

See also
getEnemies
getInrange

Definition at line 1259 of file nlua_pilot.c.

◆ pilotL_getArmour()

int pilotL_getArmour ( lua_State * L)
static

Gets the pilot's armour.

Lua usage parameter: armour = p:armour()

Lua function parameter: Pilot p Pilot to get armour of. Lua function parameter:[opt=false] boolean absolute Whether or not it shouldn't be relative and be absolute instead. Lua return parameter: number The armour in % [0:100] if relative or absolute value otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: armour

Definition at line 4856 of file nlua_pilot.c.

◆ pilotL_getColour()

int pilotL_getColour ( lua_State * L)
static

Gets the pilot's colour based on hostility or friendliness to the player.

Lua usage parameter: p:colour()

Lua function parameter: Pilot p Pilot to get the colour of. Lua return parameter: Colour The pilot's colour.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: colour

Definition at line 5308 of file nlua_pilot.c.

◆ pilotL_getDetectedDistance()

int pilotL_getDetectedDistance ( lua_State * L)
static

Gets the distance that a pilot can be currently detect at.

Lua function parameter: Pilot p Pilot to get the distance they can be detected at.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: detectedDistance

Definition at line 5066 of file nlua_pilot.c.

◆ pilotL_getEnemies()

int pilotL_getEnemies ( lua_State * L)
static

Gets hostile pilots to a pilot (or faction) within a certain distance.

Lua usage parameter: p:getEnemies( 5000 ) – get hostiles within 5000 Lua usage parameter: pilot.getEnemies( faction.get("Pirate"), 5000, vec2.new(0,0) ) – Got hostiles of "Pirate" faction 5000 units from origin

Lua function parameter: Pilot|faction pilot Pilot or to get hostiles of. Lua function parameter:[opt=infinity] number dist Distance to look for hostiles. Lua function parameter:[opt=pilot.pos] Vec2 pos Position to check from. Lua function parameter:[opt=false] boolean ignore_range Whether or not to ignore checks for pilots in range (only in the case of pilot, not faction) Lua function parameter:[opt=false] boolean disabled Whether or not to count disabled pilots. Lua function parameter:[opt=false] boolean fighters Whether or not to count deployed fighters. Lua return parameter: {Pilot,...} A table containing the pilots.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getEnemies

See also
getAllies
getInrange

Definition at line 1285 of file nlua_pilot.c.

◆ pilotL_getEnergy()

int pilotL_getEnergy ( lua_State * L)
static

Gets the pilot's energy.

Lua usage parameter: energy = p:energy()

Lua function parameter: Pilot p Pilot to get energy of. Lua function parameter:[opt=false] boolean absolute Whether or not to return the absolute numeric value instead of the relative value. Lua return parameter: number The energy of the pilot in % [0:100].

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: energy

Definition at line 4927 of file nlua_pilot.c.

◆ pilotL_getFriendOrFoe()

int pilotL_getFriendOrFoe ( lua_State * L,
int friend )
static

Definition at line 1162 of file nlua_pilot.c.

◆ pilotL_getFuel()

int pilotL_getFuel ( lua_State * L)
static

Gets the amount of fuel the pilot has.

Lua return parameter: number The amount of fuel the pilot has.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: fuel

Definition at line 4083 of file nlua_pilot.c.

◆ pilotL_getHealth()

int pilotL_getHealth ( lua_State * L)
static

Gets the pilot's health.

Lua usage parameter: armour, shield, stress, dis = p:health()

Lua function parameter: Pilot p Pilot to get health of. Lua function parameter:[opt=false] boolean absolute Whether or not it shouldn't be relative and be absolute instead. Lua return parameter: number The armour in % [0:100] if relative or absolute value otherwise. Lua return parameter: number The shield in % [0:100] if relative or absolute value otherwise. Lua return parameter: number The stress in % [0:100]. Lua return parameter: boolean Indicates if pilot is disabled.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: health

Definition at line 4825 of file nlua_pilot.c.

◆ pilotL_getHostile()

int pilotL_getHostile ( lua_State * L)
static

Returns whether the pilot is hostile to the player.

Lua usage parameter: p:hostile()

Lua function parameter: Pilot p Pilot to get the hostility of. Lua return parameter: boolean The pilot's hostility status.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hostile

Definition at line 5344 of file nlua_pilot.c.

◆ pilotL_getInrange()

int pilotL_getInrange ( lua_State * L)
static

Gets visible pilots to a pilot within a certain distance.

Lua function parameter: vec2 pos Position to get pilots in range of. Lua function parameter: number d Distance to get pilots in. Lua function parameter:[opt=false] boolean disabled Whether or not to count disabled pilots. Lua return parameter: {Pilot,...} A table containing the pilots.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getInrange

See also
getEnemies
getAllies

Definition at line 1346 of file nlua_pilot.c.

◆ pilotL_getLockon()

int pilotL_getLockon ( lua_State * L)
static

Gets the lockons on the pilot.

Lua usage parameter: lockon = p:lockon()

Lua function parameter: Pilot p Pilot to get lockons of. Lua return parameter: number The number of lockons on the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: lockon

Definition at line 4948 of file nlua_pilot.c.

◆ pilotL_getPilots()

int pilotL_getPilots ( lua_State * L)
static

Gets the pilots available in the system by a certain criteria.

Lua usage parameter: p = pilot.get() – Gets all the pilots Lua usage parameter: p = pilot.get( { faction.get("Empire") } ) – Only gets empire pilots. Lua usage parameter: p = pilot.get( nil, true ) – Gets all pilots including disabled Lua usage parameter: p = pilot.get( { faction.get("Empire") }, true ) – Only empire pilots with disabled

Lua function parameter: Faction|{Faction,...} factions If f is a table of factions, it will only get pilots matching those factions. Otherwise it gets all the pilots. Lua function parameter:[opt=false] boolean disabled Whether or not to get disabled ships. Lua return parameter: {Pilot,...} A table containing the pilots.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: get

Definition at line 1045 of file nlua_pilot.c.

◆ pilotL_getShield()

int pilotL_getShield ( lua_State * L)
static

Gets the pilot's shield.

Lua usage parameter: shield = p:shield()

Lua function parameter: Pilot p Pilot to get shield of. Lua function parameter:[opt=false] boolean absolute Whether or not it shouldn't be relative and be absolute instead. Lua return parameter: number The shield in % [0:100] if relative or absolute value otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shield

Definition at line 4880 of file nlua_pilot.c.

◆ pilotL_getShipStat()

int pilotL_getShipStat ( lua_State * L)
static

Gets a shipstat from a Pilot by name, or a table containing all the ship stats if not specified.

Lua usage parameter: local mod = p:shipstat("tur_damage",true) – Gets turret damage bonus with internal representation

Lua function parameter: Pilot p Pilot to get ship stat of. Lua function parameter:[opt=nil] string name Name of the ship stat to get. Lua function parameter:[opt=false] boolean internal Whether or not to use the internal representation. Lua return parameter: Value of the ship stat or a table containing all the ship stats if name is not specified.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shipstat

Definition at line 5051 of file nlua_pilot.c.

◆ pilotL_getStats()

int pilotL_getStats ( lua_State * L)
static

Gets stats of the pilot.

Some of the stats are:

  • cpu
  • cpu_max
  • crew
  • fuel
  • fuel_max
  • fuel_consumption
  • mass
  • accel
  • speed
  • speed_max
  • turn
  • absorb
  • armour
  • shield
  • energy
  • armour_regen
  • shield_regen
  • energy_regen
  • jump_delay
  • jumps

Lua usage parameter: stats = p:stats() print(stats.armour)

Lua function parameter: Pilot p Pilot to get stats of. Lua return parameter: table A table containing the stats of p.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: stats

Definition at line 4996 of file nlua_pilot.c.

◆ pilotL_getStress()

int pilotL_getStress ( lua_State * L)
static

Gets the pilot's stress.

Lua usage parameter: stress = p:stress()

Lua function parameter: Pilot p Pilot to get stress of. Lua function parameter:[opt=false] boolean absolute Whether or not it shouldn't be relative and be absolute instead. Lua return parameter: number The shield in % [0:100] if relative or absolute value otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: stress

Definition at line 4904 of file nlua_pilot.c.

◆ pilotL_getVisible()

int pilotL_getVisible ( lua_State * L)
static

Gets visible pilots to a pilot.

Note
This function can not use quadtrees and is much slower than getEnemies, getAllies, or getInrange.

Lua function parameter: Pilot pilot Pilot to get visible pilots of. Lua function parameter:[opt=false] boolean disabled Whether or not to count disabled pilots. Lua return parameter: {Pilot,...} A table containing the pilots.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getVisible

See also
getEnemies
getAllies
getInrange

Definition at line 1305 of file nlua_pilot.c.

◆ pilotL_hailPlayer()

int pilotL_hailPlayer ( lua_State * L)
static

Marks the pilot as hailing the player.

Automatically deactivated when pilot is hailed.

Lua usage parameter: p:hailPlayer() – Player will be informed he's being hailed and pilot will have an icon Lua function parameter: Pilot p Pilot to hail the player. Lua function parameter:[opt=true] boolean enable If true hails the pilot, if false disables the hailing.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hailPlayer

Definition at line 6337 of file nlua_pilot.c.

◆ pilotL_hasIllegal()

int pilotL_hasIllegal ( lua_State * L)
static

Checks to see if the pilot has illegal stuff to a faction.

Lua function parameter: Pilot p Pilot to check. Lua function parameter: Faction f Faction to see if it is illegal to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hasIllegal

Definition at line 5457 of file nlua_pilot.c.

◆ pilotL_hookClear()

int pilotL_hookClear ( lua_State * L)
static

Clears the pilot's hooks.

Clears all the hooks set on the pilot.

Lua usage parameter: p:hookClear() Lua function parameter: Pilot p Pilot to clear hooks.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hookClear

Definition at line 6594 of file nlua_pilot.c.

◆ pilotL_hyperspace()

int pilotL_hyperspace ( lua_State * L)
static

Tells the pilot to hyperspace.

Pilot must be under manual control for this to work.

Lua function parameter: Pilot p Pilot to tell to hyperspace. Lua function parameter:[opt] System|Jump sys Optional System to jump to, uses random if nil. Lua function parameter:[opt=false] boolean noshoot Forbids to shoot at targets with turrets while running away. See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hyperspace

Definition at line 6173 of file nlua_pilot.c.

◆ pilotL_id()

int pilotL_id ( lua_State * L)
static

Gets the ID of the pilot. Guaranteed to be unique per pilot and not repeating over time (with the exception of the player).

Lua usage parameter: id = p:id()

Lua function parameter: p Pilot Pilot to get the ID of. Lua return parameter: number The ID of the current pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: id

Definition at line 1454 of file nlua_pilot.c.

◆ pilotL_idle()

int pilotL_idle ( lua_State * L)
static

Checks to see if the pilot is idle.

Lua usage parameter: idle = p:idle() – Returns true if the pilot is idle

Lua function parameter: Pilot p Pilot to check to see if is idle. Lua return parameter: boolean true if pilot is idle, false otherwise

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: idle

Definition at line 5520 of file nlua_pilot.c.

◆ pilotL_inrange()

int pilotL_inrange ( lua_State * L)
static

Checks to see if a target pilot is in range of a pilot.

TODO add supports for spobs and jump points.

Lua usage parameter: detected, scanned = p:inrange( target )

Lua function parameter: Pilot p Pilot to see if another pilot is in range. Lua function parameter: Pilot|Asteroid|Vec2 target Target pilot or asteroid to check if in range. Lua return parameter: boolean True if the pilot is visible at all. Lua return parameter: boolean True if the pilot is visible and well-defined (not fuzzy). Always true if target is not a Pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: inrange

Definition at line 1594 of file nlua_pilot.c.

◆ pilotL_intrinsicGet()

int pilotL_intrinsicGet ( lua_State * L)
static

Allows getting an intrinsic stats of a pilot, or gets all of them if name is not specified.

Lua function parameter: Pilot p Pilot to get stat of. Lua function parameter:[opt=nil] string name Name of the stat to get. It is the same as in the xml. If nil, returns a table containing all the shipstats. Lua function parameter:[opt=false] boolean internal Whether or not to use the internal representation. Lua function parameter: Value of the stat or a table containing all the stats if name is not specified.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: intrinsicGet

Definition at line 4192 of file nlua_pilot.c.

◆ pilotL_intrinsicReset()

int pilotL_intrinsicReset ( lua_State * L)
static

Resets the intrinsic stats of a pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: intrinsicReset

Definition at line 4126 of file nlua_pilot.c.

◆ pilotL_intrinsicSet()

int pilotL_intrinsicSet ( lua_State * L)
static

Allows setting intrinsic stats of a pilot.

Lua usage parameter: p:intrinsicSet( "turn", -50 ) – Lowers p's turn by 50%

Lua function parameter: Pilot p Pilot to set stat of. Lua function parameter: string name Name of the stat to set. It is the same as in the xml. Lua function parameter: number value Value to set the stat to. Lua function parameter: boolean replace Whether or not to add to the stat or replace it.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: intrinsicSet

Definition at line 4148 of file nlua_pilot.c.

◆ pilotL_isStopped()

int pilotL_isStopped ( lua_State * L)
static

Checks to see if a pilot is stopped.

Lua usage parameter: if p:isStopped() then ... end

Lua function parameter: Pilot p Pilot to get the velocity of. Lua return parameter: boolean Whether the pilot is stopped or not.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: isStopped

Definition at line 2842 of file nlua_pilot.c.

◆ pilotL_kill()

int pilotL_kill ( lua_State * L)
static

Kills a pilot.

Can fail to kill a pilot if they have a hook that regenerates them.

Lua function parameter: Pilot p Pilot to kill.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: kill

Definition at line 6699 of file nlua_pilot.c.

◆ pilotL_knockback()

int pilotL_knockback ( lua_State * L)
static

Knocks back a pilot. It can either accept two pilots, or a pilot and an element represented by mass, velocity, and position.

Lua usage parameter: pilota:knockback( pilotb, 0. ) – Inelastic collision between pilota and pilotb Lua usage parameter: pilota:knockback( 100, vec2.new(0,0) ) – Elastic collision between a 100 mass object with no velocity and pilota

Lua function parameter: Pilot p Pilot being knocked back. Lua function parameter: number m Mass of object knocking back pilot. Lua function parameter: Vec2 v Velocity of object knocking back pilot. Lua function parameter:[opt=p:pos()] Vec2 p Position of the object knocking back the pilot. Lua function parameter:[opt=1.] number e Coefficient of restitution. Use 1. for elastic collisions, and 0. for inelastic collisions.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: knockback

Definition at line 6725 of file nlua_pilot.c.

◆ pilotL_land()

int pilotL_land ( lua_State * L)
static

Tells the pilot to land.

Pilot must be under manual control for this to work.

Lua function parameter: Pilot p Pilot to tell to land. Lua function parameter:[opt] Spob spob Spob to land on, uses random if nil. Lua function parameter:[opt=false] boolean noshoot Forbids to shoot at targets with turrets while running away. See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: land

Definition at line 6281 of file nlua_pilot.c.

◆ pilotL_leader()

int pilotL_leader ( lua_State * L)
static

Gets a pilots leader. Guaranteed to exist or will be nil.

Lua function parameter: Pilot p Pilot to get the leader of. Lua return parameter: Pilot|nil The leader or nil.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: leader

Definition at line 6434 of file nlua_pilot.c.

◆ pilotL_mass()

int pilotL_mass ( lua_State * L)
static

Gets the mass of a pilot.

Lua usage parameter: m = p:mass()

Lua function parameter: Pilot p Pilot to get mass of. Lua return parameter: number The pilot's current mass (in tonnes).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mass

Definition at line 2906 of file nlua_pilot.c.

◆ pilotL_memory()

int pilotL_memory ( lua_State * L)
static

Gets a pilots memory table.

The resulting table is indexable and mutable.

Lua usage parameter: aggr = p:memory().aggressive Lua usage parameter: p:memory().aggressive = false

Lua function parameter: Pilot p Pilot to read memory of.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: memory

Definition at line 5606 of file nlua_pilot.c.

◆ pilotL_mothership()

int pilotL_mothership ( lua_State * L)
static

Gets a pilots mothership (only exists for deployed pilots). Guaranteed to exist or will be nil.

Lua function parameter: Pilot p Pilot to get the mothership of. Lua return parameter: Pilot|nil The mothership or nil.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: mothership

Definition at line 6413 of file nlua_pilot.c.

◆ pilotL_moveto()

int pilotL_moveto ( lua_State * L)
static

Makes the pilot move to a position.

Pilot must be under manual control for this to work.

Lua usage parameter: p:moveto( v ) – Goes to v precisely and braking Lua usage parameter: p:moveto( v, true, true ) – Same as p:moveto( v ) Lua usage parameter: p:moveto( v, false ) – Goes to v without braking compensating velocity Lua usage parameter: p:moveto( v, false, false ) – Really rough approximation of going to v without braking

Lua function parameter: Pilot p Pilot to tell to go to a position. Lua function parameter: Vec2 v Vector target for the pilot. Lua function parameter:[opt=1] boolean brake If true (or nil) brakes the pilot near target position, otherwise pops the task when it is about to brake. Lua function parameter:[opt=1] boolean compensate If true (or nil) compensates for velocity, otherwise it doesn't. It only affects if brake is not set. See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: moveto

Definition at line 5868 of file nlua_pilot.c.

◆ pilotL_msg()

int pilotL_msg ( lua_State * L)
static

Sends a message to another pilot.

Do not confuse with pilot.comm! This is meant to be used by AI and other scripts.

Lua function parameter: Pilot p Pilot to send message. Lua function parameter: Pilot|{Pilot,...} receiver Pilot(s) to receive message. Lua function parameter: string type Type of message. Lua function parameter:[opt] data Data to send with message.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: msg

Definition at line 6376 of file nlua_pilot.c.

◆ pilotL_name()

int pilotL_name ( lua_State * L)
static

Gets the pilot's current (translated) name.

Lua usage parameter: name = p:name()

Lua function parameter: Pilot p Pilot to get the name of. Lua return parameter: string The current name of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: name

Definition at line 1437 of file nlua_pilot.c.

◆ pilotL_nav()

int pilotL_nav ( lua_State * L)
static

Gets the nav target of the pilot.

Lua usage parameter: spob, hyperspace = p:nav()

Lua function parameter: Pilot p Pilot to get nav info of. Lua return parameter: Spob|nil The pilot's spob target. Lua return parameter: System|nil The pilot's hyperspace target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: nav

Definition at line 1670 of file nlua_pilot.c.

◆ pilotL_navJump()

int pilotL_navJump ( lua_State * L)
static

Gets the nav jump target of the pilot.

Lua function parameter: Pilot p Pilot to get nav info of. Lua return parameter: Jump|nil The pilot's hyperspace target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: navJump

Definition at line 1720 of file nlua_pilot.c.

◆ pilotL_navJumpSet()

int pilotL_navJumpSet ( lua_State * L)
static

Sets the hyperspace navigation target for the pilot.

Lua function parameter: Pilot p Pilot to set hyperspace navigation target for. Lua function parameter: Jump|nil jp Jump point to set as navigation target or nil to disable.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: navJumpSet

Definition at line 1745 of file nlua_pilot.c.

◆ pilotL_navSpob()

int pilotL_navSpob ( lua_State * L)
static

Gets the nav spob target of the pilot.

Lua function parameter: Pilot p Pilot to get nav info of. Lua return parameter: Spob|nil The pilot's spob target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: navSpob

Definition at line 1700 of file nlua_pilot.c.

◆ pilotL_newtask()

Task * pilotL_newtask ( lua_State * L,
Pilot * p,
const char * task )
static

Does a new task.

Definition at line 5826 of file nlua_pilot.c.

◆ pilotL_outfitAdd()

int pilotL_outfitAdd ( lua_State * L)
static

Adds an outfit to a pilot.

This by default tries to add them to the first empty or defaultly equipped slot. Will not overwrite existing non-default outfits.

Lua usage parameter: added = p:outfitAdd( "Laser Cannon", 5 ) – Adds 5 laser cannons to p

Lua function parameter: Pilot p Pilot to add outfit to. Lua function parameter: string|outfit outfit Outfit or name of the outfit to add. Lua function parameter:[opt=1] number q Quantity of the outfit to add. Lua function parameter:[opt=false] boolean bypass_cpu Whether to skip CPU checks when adding an outfit. Lua function parameter:[opt=false] boolean bypass_slot Whether or not to skip slot size checks before adding an outfit. Not that this implies skipping the CPU checks. Lua return parameter: number The number of outfits added. Lua return parameter: number The id of the slot of the first outfit added if applicable.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitAdd

Definition at line 3752 of file nlua_pilot.c.

◆ pilotL_outfitAddIntrinsic()

int pilotL_outfitAddIntrinsic ( lua_State * L)
static

Adds an intrinsic outfit to the pilot.

Intrinsic outfits are outfits that are associated with a ship, but not their slots.

Lua function parameter: Pilot p Pilot to add intrinsic outfit to. Lua function parameter: Outfit o Outfit to add as intrinsic outfit (must be modifier outfit).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitAddIntrinsic

See also
outfitAdd

Definition at line 4042 of file nlua_pilot.c.

◆ pilotL_outfitAddSlot()

int pilotL_outfitAddSlot ( lua_State * L)
static

Adds an outfit to a pilot by slot name.

Lua function parameter: Pilot p Pilot to add outfit to. Lua function parameter: string|outfit outfit Outfit or name of the outfit to add. Lua function parameter: string|integer slot Slot to add to. Can be passed as a slot name (string) or slot id (integer). Lua function parameter:[opt=false] boolean bypass_cpu Whether to skip CPU checks when adding an outfit. Lua function parameter:[opt=false] boolean|string bypass_slot Whether or not to skip slot size checks before adding an outfit. Not that this implies skipping the CPU checks. In the case bypass_slot is a string, the outfit gets added to the named slot if possible (no slot check). Lua return parameter: boolean Whether or not the outfit was added.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitAddSlot

Definition at line 3852 of file nlua_pilot.c.

◆ pilotL_outfitGet()

int pilotL_outfitGet ( lua_State * L)
static

Gets a pilot's outfit by ID.

Lua function parameter: Pilot p Pilot to get outfit of. Lua function parameter: number id ID of the outfit to get. Lua return parameter: Outfit|nil Outfit equipped in the slot or nil otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitGet

Definition at line 2674 of file nlua_pilot.c.

◆ pilotL_outfitReady()

int pilotL_outfitReady ( lua_State * L)
static

Sees if an outfit is ready to use.

Lua function parameter: Pilot p Pilot to toggle outfit of. Lua function parameter: integer id ID of the pilot outfit. Lua return parameter: boolean Whether or not the outfit is ready to use.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitReady

Definition at line 2763 of file nlua_pilot.c.

◆ pilotL_outfitRm()

int pilotL_outfitRm ( lua_State * L)
static

Removes an outfit from a pilot.

"all" will remove all outfits except cores, locked outfits, and intrinsic outfits. "cores" will remove all cores, but nothing else. "intrinsic" will remove all intrinsic outfits.

Lua usage parameter: p:outfitRm( "all" ) – Leaves the pilot naked (except for cores and locked outfits). Lua usage parameter: p:outfitRm( "cores" ) – Strips the pilot of its cores, leaving it dead in space. Lua usage parameter: p:outfitRm( "intrinsic" ) – Removes all the intrinsic outfits of the ship. Lua usage parameter: p:outfitRm( "Neutron Disruptor" ) – Removes a neutron disruptor. Lua usage parameter: p:outfitRm( "Neutron Disruptor", 2 ) – Removes two neutron disruptor.

Lua function parameter: Pilot p Pilot to remove outfit from. Lua function parameter: string|outfit outfit Outfit or name of the outfit to remove. Lua function parameter: number q Quantity of the outfit to remove. Lua return parameter: number The number of outfits removed.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitRm

Definition at line 3915 of file nlua_pilot.c.

◆ pilotL_outfitRmIntrinsic()

int pilotL_outfitRmIntrinsic ( lua_State * L)
static

Removes an intrinsic outfit from the pilot.

Intrinsic outfits are outfits that are associated with a ship, but not their slots.

Lua function parameter: Pilot p Pilot to remove intrinsic outfit from. Lua function parameter: Outfit o Outfit to remove from intrinsic outfits. Lua return parameter: boolean true if outfit was removed, false otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitRmIntrinsic

See also
outfitRm

Definition at line 4069 of file nlua_pilot.c.

◆ pilotL_outfitRmSlot()

int pilotL_outfitRmSlot ( lua_State * L)
static

Removes an outfit from a pilot's named slot.

Note that this only works with the name="foo" property of slots. It is not meant to be used with unnamed slots. By default all slots are unnamed unless specified.

Lua function parameter: Pilot p Pilot to remove outfit from. Lua function parameter: string|integer slot Slot to remove from. Can be passed as a slot name (string) or slot id (integer). Lua return parameter: boolean true on success.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitRmSlot

See also
outfitRm

Definition at line 4009 of file nlua_pilot.c.

◆ pilotL_outfits()

int pilotL_outfits ( lua_State * L)
static

Gets a mapping of outfit slot IDs and outfits of a pilot.

Note
The index value can be used as a slot identifier.

Lua function parameter: Pilot p Pilot to get outfits of. Lua return parameter: table Ordered table of outfits. If an outfit is not equipped at slot it sets the value to false.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfits

Definition at line 2602 of file nlua_pilot.c.

◆ pilotL_outfitsEquip()

int pilotL_outfitsEquip ( lua_State * L)
static

Equips a pilot with a set of outfits.

Lua function parameter: Pilot p Pilot to set equipment of. Lua function parameter: table o Table of outfits to equip the pilot (should be likely taken from pilot.outfits). The key should be the slot id and the value should be the outfit or false if there is no outfit in that slot. Lua return parameter: boolean If all the outfits were equipped successfully or not.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitsEquip

See also
outfits

Definition at line 2627 of file nlua_pilot.c.

◆ pilotL_outfitsList()

int pilotL_outfitsList ( lua_State * L)
static

Gets the outfits of a pilot.

Lua function parameter: Pilot p Pilot to get outfits of. Lua function parameter:[opt=nil] string What slot type to get outfits of. Can be either nil, "weapon", "utility", "structure", "intrinsic", or "all". nil implies returning all non-intrinsic outfits. Lua function parameter:[opt=false] boolean skip_locked Whether or not locked outfits should be ignored. Lua return parameter: table The outfits of the pilot in an ordered list.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitsList

Definition at line 2534 of file nlua_pilot.c.

◆ pilotL_outfitSlot()

int pilotL_outfitSlot ( lua_State * L)
static

Checks to see outfit a pilot has in a slot.

Lua function parameter: Pilot p Pilot to check outfit slot of. Lua function parameter: string|integer slot Slot to check. Can be passed as a slot name (string) or slot id (integer). Lua return parameter: Outfit|nil Outfit if applicable or nil otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitSlot

Definition at line 3823 of file nlua_pilot.c.

◆ pilotL_outfitToggle()

int pilotL_outfitToggle ( lua_State * L)
static

Toggles an outfit.

Lua function parameter: Pilot p Pilot to toggle outfit of. Lua function parameter: table|integer id ID of the pilot outfit, or table of pilot outfit ids. Lua function parameter:[opt=false] boolean activate Whether or not to activate or deactivate the outfit.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitToggle

Definition at line 2726 of file nlua_pilot.c.

◆ pilotL_points()

int pilotL_points ( lua_State * L)
static

Gets the points the pilot costs.

Note currently equivalent to p:ship():points().

Lua function parameter: Pilot p Pilot to get points of. Lua return parameter: number The points of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: points

Definition at line 5504 of file nlua_pilot.c.

◆ pilotL_poptask()

int pilotL_poptask ( lua_State * L)
static

Pops the current task from the pilot's AI.

Equivalent to ai.poptask().

Lua function parameter: Pilot p Pilot to pop task from.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: poptask

Definition at line 5789 of file nlua_pilot.c.

◆ pilotL_position()

int pilotL_position ( lua_State * L)
static

Gets the pilot's position.

Lua usage parameter: v = p:pos()

Lua function parameter: Pilot p Pilot to get the position of. Lua return parameter: Vec2 The pilot's current position.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pos

Definition at line 2810 of file nlua_pilot.c.

◆ pilotL_pushtask()

int pilotL_pushtask ( lua_State * L)
static

Pushes a new task to the pilot's AI.

Equivalent to ai.pushtask()

Lua function parameter: Pilot p Pilot to push task to. Lua function parameter: string func Name of the function to be run. Lua function parameter: any data Data to be passed to the function.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pushtask

Definition at line 5765 of file nlua_pilot.c.

◆ pilotL_radius()

int pilotL_radius ( lua_State * L)
static

Gets the rough radius of the ship, useful for collision stuff.

Lua function parameter: Pilot p Pilot to get radius of. Lua return parameter: number THe radius of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: radius

Definition at line 5488 of file nlua_pilot.c.

◆ pilotL_refuel()

int pilotL_refuel ( lua_State * L)
static

Tries to refuel a pilot.

Lua function parameter: Pilot p Pilot to do the refueling. Lua function parameter: Pilot target Target pilot to give fuel to. Lua function parameter:[opt=100] number amount Amount to refuel.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: refuel

Definition at line 5809 of file nlua_pilot.c.

◆ pilotL_remove()

int pilotL_remove ( lua_State * L)
static

Removes a pilot without explosions or anything.

Does nothing if the pilot does not exist.

Lua usage parameter: p:rm() – pilot will be destroyed

Lua function parameter: Pilot p Pilot to remove.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rm

Definition at line 852 of file nlua_pilot.c.

◆ pilotL_rename()

int pilotL_rename ( lua_State * L)
static

Changes the pilot's name.

Lua usage parameter: p:rename( _("Black Beard") )

Lua function parameter: Pilot p Pilot to change name of. Lua function parameter: string name Name to change to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rename

Definition at line 2788 of file nlua_pilot.c.

◆ pilotL_render()

int pilotL_render ( lua_State * L)
static

Renders the pilot to a canvas.

Lua function parameter: Pilot p Pilot whose ship is being rendered. Lua return parameter: Canvas The canvas with the pilot drawn on it.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: render

Definition at line 6940 of file nlua_pilot.c.

◆ pilotL_renderComm()

int pilotL_renderComm ( lua_State * L)
static

Renders the pilot communication image.

Definition at line 6918 of file nlua_pilot.c.

◆ pilotL_renderTo()

int pilotL_renderTo ( lua_State * L)
static

Renders the pilot to a canvas.

Lua function parameter: Pilot p Pilot whose ship is being rendered. Lua function parameter: Canvas The canvas to draw to (uses bottom-left corner). Lua return parameter: number Width drawn. Lua return parameter: number Height drawn.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: renderTo

Definition at line 6976 of file nlua_pilot.c.

◆ pilotL_reputation()

int pilotL_reputation ( lua_State * L)
static

Get the reputation the player has with the pilot's faction.

Lua function parameter: Pilot p Pilot to get the reputation with. Lua return parameter: number The reputation with the pilot's faction.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: reputation

Definition at line 2995 of file nlua_pilot.c.

◆ pilotL_runaway()

int pilotL_runaway ( lua_State * L)
static

Makes the pilot runaway from another pilot.

By default the pilot tries to jump when running away. Third argument is destination: if false or nil, destination is automatically chosen. If true, the pilot does not jump nor land and stays in system. If Jump is given, the pilot tries to use this jump to go hyperspace. If Spob is given, the pilot tries to land on it.

Lua usage parameter: p:runaway( p_enemy ) – Run away from p_enemy Lua usage parameter: p:runaway( p_enemy, true ) – Run away from p_enemy but do not jump Lua function parameter: Pilot p Pilot to tell to runaway from another pilot. Lua function parameter: Pilot tp Target pilot to runaway from. Lua function parameter:[opt=false] boolean|Jump|Spob destination. See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: runaway

Definition at line 6087 of file nlua_pilot.c.

◆ pilotL_scandone()

int pilotL_scandone ( lua_State * L)
static

Checks to see if a pilot is done scanning its target.

Lua return parameter: boolean True if the pilot has finished scanning their target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: scandone

Definition at line 1635 of file nlua_pilot.c.

◆ pilotL_setActiveBoard()

int pilotL_setActiveBoard ( lua_State * L)
static

Allows the pilot to be boarded when not disabled.

Lua usage parameter: p:setActiveBoard( true )

Lua function parameter: Pilot p Pilot to set boardability of. Lua function parameter:[opt=true] boolean state State to set boardability.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setActiveBoard

Definition at line 3506 of file nlua_pilot.c.

◆ pilotL_setBribed()

int pilotL_setBribed ( lua_State * L)
static

Makes pilot act as if bribed by the player.

Lua usage parameter: p:setBribed( true )

Lua function parameter: Pilot p Pilot to set bribed status of. Lua function parameter:[opt=true] boolean state State to set bribed.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setHilight

Definition at line 3492 of file nlua_pilot.c.

◆ pilotL_setCooldown()

int pilotL_setCooldown ( lua_State * L)
static

Starts or stops a pilot's cooldown mode.

Lua usage parameter: p:setCooldown( true )

Lua function parameter: Pilot p Pilot to modify the cooldown status of. Lua function parameter:[opt=true] boolean state Whether to enable or disable cooldown.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setCooldown

Definition at line 3602 of file nlua_pilot.c.

◆ pilotL_setDir()

int pilotL_setDir ( lua_State * L)
static

Sets the pilot's direction.

Note
Right is 0, top is math.pi/2, left is math.pi, bottom is 3*math.pi/2.

Lua usage parameter: p:setDir( math.pi/2 )

Lua function parameter: Pilot p Pilot to set the direction of. Lua function parameter: number dir Direction to set, in radians.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setDir

Definition at line 3115 of file nlua_pilot.c.

◆ pilotL_setDisable()

int pilotL_setDisable ( lua_State * L)
static

Disables a pilot.

Lua usage parameter: p:disable()

Lua function parameter: Pilot p Pilot to disable. Lua function parameter:[opt=false] boolean nopermanent Whether or not the disable should be not permanent.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setDisable

Definition at line 3556 of file nlua_pilot.c.

◆ pilotL_setEnergy()

int pilotL_setEnergy ( lua_State * L)
static

Sets the energy of a pilot.

Lua usage parameter: p:setEnergy( 100 ) – Sets pilot to full energy. Lua usage parameter: p:setEnergy( 70 ) – Sets pilot to 70% energy.

Lua function parameter: Pilot p Pilot to set energy of. Lua function parameter: number energy Value to set energy to, should be double from 0-100 (in percent). Lua function parameter:[opt=false] boolean absolute Whether or not it is being set in relative value or absolute.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setEnergy

Definition at line 4675 of file nlua_pilot.c.

◆ pilotL_setFaction()

int pilotL_setFaction ( lua_State * L)
static

Sets the pilot's faction.

Lua usage parameter: p:setFaction( "Empire" ) Lua usage parameter: p:setFaction( faction.get( "Dvaered" ) )

Lua function parameter: Pilot p Pilot to change faction of. Lua function parameter: Faction faction Faction to set by name or faction.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setFaction

Definition at line 3278 of file nlua_pilot.c.

◆ pilotL_setFlagWrapper()

int pilotL_setFlagWrapper ( lua_State * L,
int flag )
static

Wrapper to simplify flag setting stuff.

Definition at line 495 of file nlua_pilot.c.

◆ pilotL_setFriendly()

int pilotL_setFriendly ( lua_State * L)
static

Controls the pilot's friendliness towards the player.

Lua usage parameter: p:setFriendly() – Pilot is now friendly. Lua usage parameter: p:setFriendly(false) – Make pilot non-friendly.

Lua function parameter: Pilot p Pilot to set the friendliness of. Lua function parameter:[opt=true] boolean state Whether to set or unset friendly.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setFriendly

Definition at line 3329 of file nlua_pilot.c.

◆ pilotL_setFuel()

int pilotL_setFuel ( lua_State * L)
static

Sets the fuel of a pilot.

Lua usage parameter: p:setFuel( true ) – Sets fuel to max

Lua function parameter: Pilot p Pilot to set fuel of. Lua function parameter: boolean|number f true sets fuel to max, false sets fuel to 0, a number sets fuel to that amount in units. Lua return parameter: number The amount of fuel the pilot has.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setFuel

Definition at line 4101 of file nlua_pilot.c.

◆ pilotL_setHealth()

int pilotL_setHealth ( lua_State * L)
static

Sets the health of a pilot.

This recovers the pilot's disabled state, although they may become disabled afterwards.

Lua usage parameter: p:setHealth( 100, 100 ) – Sets pilot to full health Lua usage parameter: p:setHealth( 70, 0 ) – Sets pilot to 70% armour Lua usage parameter: p:setHealth( 100, 100, 0 ) – Sets pilot to full health and no stress

Lua function parameter: Pilot p Pilot to set health of. Lua function parameter:[opt=current armour] number armour Value to set armour to, should be double from 0-100 (in percent). Lua function parameter:[opt=current shield] number shield Value to set shield to, should be double from 0-100 (in percent). Lua function parameter:[opt=0] number stress Value to set stress (disable damage) to, should be double from 0-100 (in percent of current armour).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setHealth

Definition at line 4545 of file nlua_pilot.c.

◆ pilotL_setHealthAbs()

int pilotL_setHealthAbs ( lua_State * L)
static

Sets the health of a pilot in absolute value.

This recovers the pilot's disabled state, although they may become disabled afterwards.

Lua function parameter: Pilot p Pilot to set health of. Lua function parameter:[opt=current armour] number armour Value to set armour to, in absolute value. Lua function parameter:[opt=current shield] number shield Value to set shield to, in absolute value Lua function parameter:[opt=current stress] number stress Value to set stress (disable damage) to, in absolute value.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setHealth

Definition at line 4598 of file nlua_pilot.c.

◆ pilotL_setHide()

int pilotL_setHide ( lua_State * L)
static

Sets the pilot's hide status.

A hidden pilot is neither updated nor drawn. It stays frozen in time until the hide is lifted.

Lua usage parameter: p:setHide() – p will disappear Lua usage parameter: p:setHide(true) – p will disappear Lua usage parameter: p:setHide(false) – p will appear again

Lua function parameter: Pilot p Pilot to set hidden status of. Lua function parameter: boolean state State to set hide.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setHide

Definition at line 3398 of file nlua_pilot.c.

◆ pilotL_setHilight()

int pilotL_setHilight ( lua_State * L)
static

Makes pilot stand out on radar and the likes.

This makes the pilot stand out in the map overlay and radar to increase noticability.

Lua usage parameter: p:setHilight( true )

Lua function parameter: Pilot p Pilot to set hilight status of. Lua function parameter:[opt=true] boolean state State to set hilight.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setHilight

Definition at line 3478 of file nlua_pilot.c.

◆ pilotL_setHostile()

int pilotL_setHostile ( lua_State * L)
static

Controls the pilot's hostility towards the player.

Lua usage parameter: p:setHostile() – Pilot is now hostile. Lua usage parameter: p:setHostile(false) – Make pilot non-hostile.

Lua function parameter: Pilot p Pilot to set the hostility of. Lua function parameter:[opt=true] boolean state Whether to set or unset hostile.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setHostile

Definition at line 3298 of file nlua_pilot.c.

◆ pilotL_setInvincible()

int pilotL_setInvincible ( lua_State * L)
static

Sets the pilot's invincibility status.

Lua usage parameter: p:setInvincible() – p can not be hit anymore Lua usage parameter: p:setInvincible(true) – p can not be hit anymore Lua usage parameter: p:setInvincible(false) – p can be hit again

Lua function parameter: Pilot p Pilot to set invincibility status of. Lua function parameter:[opt=true] boolean state State to set invincibility.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setInvincible

Definition at line 3362 of file nlua_pilot.c.

◆ pilotL_setInvincPlayer()

int pilotL_setInvincPlayer ( lua_State * L)
static

Sets the pilot's invincibility status towards the player.

Lua usage parameter: p:setInvincPlayer() – p can not be hit by the player anymore Lua usage parameter: p:setInvincPlayer(true) – p can not be hit by the player anymore Lua usage parameter: p:setInvincPlayer(false) – p can be hit by the player again

Lua function parameter: Pilot p Pilot to set invincibility status of (only affects player). Lua function parameter:[opt=true] boolean state State to set invincibility.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setInvincPlayer

Definition at line 3379 of file nlua_pilot.c.

◆ pilotL_setInvisible()

int pilotL_setInvisible ( lua_State * L)
static

Sets the pilot's invisibility status.

An invisible pilot is not shown on the radar nor targettable, however, it renders and updates just like normal.

Lua function parameter: Pilot p Pilot to set invisibility status of. Lua function parameter: boolean state State to set invisibility.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setInvisible

Definition at line 3413 of file nlua_pilot.c.

◆ pilotL_setLeader()

int pilotL_setLeader ( lua_State * L)
static

Set a pilots leader.

If leader has a leader itself, the leader will instead be set to that pilot's leader. The leader can not be set for deployed fighters or members of the player's fleet.

Lua function parameter: Pilot p Pilot to set the leader of. Lua function parameter: Pilot|nil leader Pilot to set as leader.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setLeader

Definition at line 6460 of file nlua_pilot.c.

◆ pilotL_setNoBoard()

int pilotL_setNoBoard ( lua_State * L)
static

Sets the ability to board the pilot.

No parameter is equivalent to true.

Lua usage parameter: p:setNoBoard( true ) – Pilot can not be boarded by anyone

Lua function parameter: Pilot p Pilot to set disable boarding. Lua function parameter:[opt=true] number noboard If true it disallows boarding of the pilot, otherwise it allows boarding which is the default.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setNoBoard

Definition at line 4731 of file nlua_pilot.c.

◆ pilotL_setNoClear()

int pilotL_setNoClear ( lua_State * L)
static

Enables or disables making the the pilot exempt from pilot.clear().

Lua usage parameter: p:setNoClear( true )

Lua function parameter: Pilot p Pilot to modify. Lua function parameter:[opt] boolean state true or false

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setNoClear

Definition at line 3676 of file nlua_pilot.c.

◆ pilotL_setNoDeath()

int pilotL_setNoDeath ( lua_State * L)
static

Makes it so the pilot never dies, stays at 1. armour.

Lua usage parameter: p:setNoDeath( true ) – Pilot will never die

Lua function parameter: Pilot p Pilot to set never die state of. Lua function parameter:[opt=true] boolean state Whether or not to set never die state.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setNoDeath

Definition at line 3534 of file nlua_pilot.c.

◆ pilotL_setNoDisable()

int pilotL_setNoDisable ( lua_State * L)
static

Sets the ability of the pilot to be disabled.

No parameter is equivalent to true.

Lua usage parameter: p:setNoDisable( true ) – Pilot can not be disabled anymore.

Lua function parameter: Pilot p Pilot to set disable disabling. Lua function parameter:[opt=true] boolean disable If true it disallows disabled of the pilot, otherwise it allows disabling which is the default.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setNoDisable

Definition at line 4761 of file nlua_pilot.c.

◆ pilotL_setNoJump()

int pilotL_setNoJump ( lua_State * L)
static

Enables or disables a pilot's hyperspace engine.

Lua usage parameter: p:setNoJump( true )

Lua function parameter: Pilot p Pilot to modify. Lua function parameter:[opt=true] boolean state true or false

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setNoJump

Definition at line 3648 of file nlua_pilot.c.

◆ pilotL_setNoLand()

int pilotL_setNoLand ( lua_State * L)
static

Enables or disables landing for a pilot.

Lua usage parameter: p:setNoLand( true )

Lua function parameter: Pilot p Pilot to modify. Lua function parameter:[opt] boolean state true or false

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setNoLand

Definition at line 3662 of file nlua_pilot.c.

◆ pilotL_setNoRender()

int pilotL_setNoRender ( lua_State * L)
static

Sets the pilot's norender status.

The pilot still acts normally but is just not visible and can still take damage. Meant to be used in conjunction with other flags like "invisible".

Lua function parameter: Pilot p Pilot to set norender status of. Lua function parameter: boolean state State to set norender.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setInvisible

Definition at line 3428 of file nlua_pilot.c.

◆ pilotL_setPosition()

int pilotL_setPosition ( lua_State * L)
static

Sets the pilot's position.

Lua usage parameter: p:setPos( vec2.new( 300, 200 ) )

Lua function parameter: Pilot p Pilot to set the position of. Lua function parameter: Vec2 pos Position to set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setPos

Definition at line 3065 of file nlua_pilot.c.

◆ pilotL_setSpeedLimit()

int pilotL_setSpeedLimit ( lua_State * L)
static

Limits the speed of a pilot.

Note
Can increase the pilot's speed limit over what would be physically possible.

Lua usage parameter: p:setSpeedLimit( 100 ) – Sets maximumspeed to 100px/s. Lua usage parameter: p:setSpeedLimit( 0 ) removes speed limit. Lua function parameter: pilot p Pilot to set speed of. Lua function parameter: number speed Value to set speed to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setSpeedLimit

Definition at line 4792 of file nlua_pilot.c.

◆ pilotL_setTarget()

int pilotL_setTarget ( lua_State * L)
static

Sets the pilot target of the pilot.

Lua function parameter: Pilot p Pilot to get target of. Lua function parameter: Pilot|nil t Pilot to set the target to or nil to set no target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setTarget

Definition at line 1518 of file nlua_pilot.c.

◆ pilotL_setTargetAsteroid()

int pilotL_setTargetAsteroid ( lua_State * L)
static

Sets the pilot's asteroid target.

Lua function parameter: Pilot p Pilot to set asteroid target of. Lua function parameter: Asteroid a Asteroid to set pilot's target to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setTargetAsteroid

Definition at line 1563 of file nlua_pilot.c.

◆ pilotL_setTemp()

int pilotL_setTemp ( lua_State * L)
static

Sets the temperature of a pilot.

All temperatures are in Kelvins. Note that temperatures cannot go below the base temperature of the Naev galaxy, which is 250K.

Lua usage parameter: p:setTemp( 300, true ) – Sets ship temperature to 300K, as well as all outfits. Lua usage parameter: p:setTemp( 500, false ) – Sets ship temperature to 500K, but leaves outfits alone. Lua usage parameter: p:setTemp( 0 ) – Sets ship temperature to the base temperature, as well as all outfits.

Lua function parameter: Pilot p Pilot to set health of. Lua function parameter: number temp Value to set temperature to. Values below base temperature will be clamped. Lua function parameter:[opt=false] boolean noslots Whether slots should also be set to this temperature.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setTemp

Definition at line 4501 of file nlua_pilot.c.

◆ pilotL_setVelocity()

int pilotL_setVelocity ( lua_State * L)
static

Sets the pilot's velocity.

Lua usage parameter: p:setVel( vec2.new( 300, 200 ) )

Lua function parameter: Pilot p Pilot to set the velocity of. Lua function parameter: Vec2 vel Velocity to set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setVel

Definition at line 3093 of file nlua_pilot.c.

◆ pilotL_setVisible()

int pilotL_setVisible ( lua_State * L)
static

Marks the pilot as always visible for other pilots.

This cancels out ewarfare visibility ranges and affects every pilot.

Lua usage parameter: p:setVisible( true )

Lua function parameter: Pilot p Pilot to set visibility status of. Lua function parameter:[opt=true] boolean state State to set visibility.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setVisible

Definition at line 3461 of file nlua_pilot.c.

◆ pilotL_setVisplayer()

int pilotL_setVisplayer ( lua_State * L)
static

Marks the pilot as always visible for the player.

This cancels out ewarfare visibility ranges and only affects the visibility of the player.

Lua usage parameter: p:setVisplayer( true )

Lua function parameter: Pilot p Pilot to set player visibility status of. Lua function parameter:[opt=true] boolean state State to set player visibility.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setVisplayer

Definition at line 3445 of file nlua_pilot.c.

◆ pilotL_ship()

int pilotL_ship ( lua_State * L)
static

Gets the pilot's ship.

Lua usage parameter: s = p:ship()

Lua function parameter: Pilot p Pilot to get ship of. Lua return parameter: Ship The ship of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: ship

Definition at line 5474 of file nlua_pilot.c.

◆ pilotL_shipmemory()

int pilotL_shipmemory ( lua_State * L)
static

Gets a pilots ship memory table.

The resulting table is indexable and mutable.

Lua function parameter: Pilot p Pilot to get ship memory of.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: memory

Definition at line 5624 of file nlua_pilot.c.

◆ pilotL_shippropGet()

int pilotL_shippropGet ( lua_State * L)
static

Allows getting an ship property stats of a pilot, or gets all of them if name is not specified.

Lua function parameter: Pilot p Pilot to get stat of. Lua function parameter:[opt=nil] string name Name of the stat to get. It is the same as in the xml. Lua function parameter:[opt=false] boolean internal Whether or not to use the internal representation. Lua function parameter: Value of the stat or a table containing all the stats if name is not specified.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shippropGet

Definition at line 4279 of file nlua_pilot.c.

◆ pilotL_shippropReset()

int pilotL_shippropReset ( lua_State * L)
static

Resets the ship property stats of a pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shippropReset

Definition at line 4210 of file nlua_pilot.c.

◆ pilotL_shippropSet()

int pilotL_shippropSet ( lua_State * L)
static

Allows setting ship property stats of a pilot.

Lua usage parameter: p:shippropSet( "turn", -50 ) – Lowers p's turn by 50%

Lua function parameter: Pilot p Pilot to set stat of. Lua function parameter: string name Name of the stat to set. It is the same as in the xml. Lua function parameter: number value Value to set the stat to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shippropSet

Definition at line 4230 of file nlua_pilot.c.

◆ pilotL_shipvarPeek()

int pilotL_shipvarPeek ( lua_State * L)
static

Peeks at a ship variable.

Lua usage parameter: local exp = p:shipvarPeek( "exp" ) – Checks the value of the "exp" ship var on the player's current ship

Lua function parameter: Pilot p Pilot whose ship variable is being manipulated. Lua function parameter: string varname Name of the variable to check value of. Lua function parameter:[opt] string shipname Name of the ship to check variable of. Defaults to pilot's current ship.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shipvarPeek

Definition at line 6869 of file nlua_pilot.c.

◆ pilotL_shipvarPop()

int pilotL_shipvarPop ( lua_State * L)
static

Pops a ship variable.

Lua function parameter: Pilot p Pilot whose ship variable is being manipulated. Lua function parameter: string varname Name of the variable to pop.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shipvarPop

Definition at line 6905 of file nlua_pilot.c.

◆ pilotL_shipvarPush()

int pilotL_shipvarPush ( lua_State * L)
static

Pushes a ship variable.

Lua function parameter: Pilot p Pilot whose ship variable is being manipulated. Lua function parameter: string varname Name of the variable to set value of. Lua function parameter: val Value to push.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: shipvarPush

Definition at line 6887 of file nlua_pilot.c.

◆ pilotL_signature()

int pilotL_signature ( lua_State * L)
static

Gets the pilot's signature.

Lua usage parameter: d = p:signature()

Lua function parameter: Pilot p Pilot to get the signature of. Lua return parameter: number The pilot's current signature value.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: signature

Definition at line 2858 of file nlua_pilot.c.

◆ pilotL_spaceworthy()

int pilotL_spaceworthy ( lua_State * L)
static

Checks the pilot's spaceworthiness.

Message can be non-null even if spaceworthy.

Lua usage parameter: spaceworthy = p:spaceworthy()

Lua function parameter: Pilot p Pilot to get the spaceworthy status of. Lua return parameter: boolean Whether the pilot's ship is spaceworthy. Lua return parameter: string Reason why the pilot is not spaceworthy.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: spaceworthy

Definition at line 3046 of file nlua_pilot.c.

◆ pilotL_speed()

int pilotL_speed ( lua_State * L)
static

Gets the speed of a pilot.

Note that this is not current velocity.

Lua function parameter: Pilot p Pilot to get speed of. Lua return parameter: number The pilot's current speed.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: speed

Definition at line 2936 of file nlua_pilot.c.

◆ pilotL_speed_max()

int pilotL_speed_max ( lua_State * L)
static

Gets the maximum speed of a pilot.

Lua function parameter: Pilot p Pilot to get maximum speed of. Lua return parameter: number The pilot's current maximum speed.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: speedMax

See also
speed

Definition at line 2951 of file nlua_pilot.c.

◆ pilotL_stealth()

int pilotL_stealth ( lua_State * L)
static

Tells the pilot to try to stealth.

Pilot must be under manual control for this to work.

Lua function parameter: Pilot p Pilot to tell to try to stealth. See also: control

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: stealth

Definition at line 6232 of file nlua_pilot.c.

◆ pilotL_target()

int pilotL_target ( lua_State * L)
static

Gets the pilot target of the pilot.

Lua usage parameter: target = p:target()

Lua function parameter: Pilot p Pilot to get target of. Lua return parameter: Pilot|nil nil if no target is selected, otherwise the target of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: target

Definition at line 1500 of file nlua_pilot.c.

◆ pilotL_targetAsteroid()

int pilotL_targetAsteroid ( lua_State * L)
static

Gets the asteroid target of the pilot.

Lua usage parameter: target = p:targetAsteroid()

Lua function parameter: Pilot p Pilot to get asteroid target of. Lua return parameter: table|nil nil if no asteroid is selected, otherwise a table with information about the selected asteroid.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: targetAsteroid

Definition at line 1543 of file nlua_pilot.c.

◆ pilotL_task()

int pilotL_task ( lua_State * L)
static

Gets the name and data of a pilot's current task.

Lua function parameter: Pilot p Pilot to get task data of. Lua return parameter: string Name of the task. Lua return parameter: Data of the task.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: task

Definition at line 5660 of file nlua_pilot.c.

◆ pilotL_taskclear()

int pilotL_taskclear ( lua_State * L)
static

Clears all the tasks of the pilot.

Lua usage parameter: p:taskClear()

Lua function parameter: Pilot p Pilot to clear tasks of.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: taskClear

Definition at line 5748 of file nlua_pilot.c.

◆ pilotL_taskdata()

int pilotL_taskdata ( lua_State * L)
static

Gets the data of the task the pilot is currently doing.

Lua function parameter: Pilot p Pilot to get task data of. Lua return parameter: Data of the task.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: taskdata

Definition at line 5729 of file nlua_pilot.c.

◆ pilotL_taskname()

int pilotL_taskname ( lua_State * L)
static

Gets the name of the task the pilot is currently doing.

Lua function parameter: Pilot p Pilot to get task name of. Lua return parameter: string Name of the task. Lua return parameter: string|nil Name of the subtask if applicable, or nil otherwise.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: taskname

Definition at line 5684 of file nlua_pilot.c.

◆ pilotL_taskstack()

int pilotL_taskstack ( lua_State * L)
static

Gets the name of all the pilot's current tasks (not subtasks).

Lua function parameter: Pilot p Pilot to get task stack of.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: taskstack

Definition at line 5705 of file nlua_pilot.c.

◆ pilotL_temp()

int pilotL_temp ( lua_State * L)
static

Gets the temperature of a pilot.

Lua usage parameter: t = p:temp()

Lua function parameter: Pilot p Pilot to get temperature of. Lua return parameter: number The pilot's current temperature (in kelvin).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: temp

Definition at line 2890 of file nlua_pilot.c.

◆ pilotL_toggleSpawn()

int pilotL_toggleSpawn ( lua_State * L)
static

Disables or enables pilot spawning in the current system.

If player jumps the spawn is enabled again automatically. Global spawning takes priority over faction spawning.

Lua usage parameter: pilot.toggleSpawn() – Defaults to disabling global spawning Lua usage parameter: pilot.toggleSpawn( false ) – Disables global spawning Lua usage parameter: pilot.toggleSpawn( "Pirate" ) – Defaults to disabling pirate spawning Lua usage parameter: pilot.toggleSpawn( "Pirate", true ) – Turns on pirate spawning

Lua function parameter:[opt] Faction|table fac Faction or table of factions to enable or disable spawning off. If ommited it works on global spawning. Lua function parameter:[opt=false] boolean enable true enables spawn, false disables it. Lua return parameter: boolean The current spawn state.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: toggleSpawn

Definition at line 1001 of file nlua_pilot.c.

◆ pilotL_tostring()

int pilotL_tostring ( lua_State * L)
static

Gets the pilot's current (translated) name or notes it is inexistent.

Lua usage parameter: tostring(p)

Lua function parameter: Pilot p Pilot to convert to string. Lua return parameter: string The current name of the pilot or "(inexistent pilot)" if not existent.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __tostring

Definition at line 1417 of file nlua_pilot.c.

◆ pilotL_tryStealth()

int pilotL_tryStealth ( lua_State * L)
static

Tries to make the pilot stealth.

Lua function parameter: Pilot p Pilot to try to make stealth. Lua return parameter: boolean Whether or not the pilot was able to stealth.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: tryStealth

Definition at line 6248 of file nlua_pilot.c.

◆ pilotL_turn()

int pilotL_turn ( lua_State * L)
static

Gets the turn of a pilot.

Lua function parameter: Pilot p Pilot to get turn of. Lua return parameter: number The pilot's current turn (in degrees per second).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: turn

Definition at line 2965 of file nlua_pilot.c.

◆ pilotL_velocity()

int pilotL_velocity ( lua_State * L)
static

Gets the pilot's velocity.

Lua usage parameter: vel = p:vel()

Lua function parameter: Pilot p Pilot to get the velocity of. Lua return parameter: Vec2 The pilot's current velocity.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: vel

Definition at line 2826 of file nlua_pilot.c.

◆ pilotL_weapset()

int pilotL_weapset ( lua_State * L)
static

Gets the weapset weapon of the pilot.

The weapon sets have the following structure:

  • outfit: the outfit.
  • cooldown: [0:1] value indicating if ready to shoot (1 is ready).
  • charge: [0:1] charge level of beam weapon (1 is full).
  • left: Absolute ammo left or nil if not applicable.
  • left_p: Relative ammo left [0:1] or nil if not applicable
  • lockon: Lock-on [0:1] for seeker weapons or nil if not applicable.
  • in_arc: Whether or not the target is in targeting arc or nil if not applicable.
  • active: Whether or not the weapon is currently active.
  • heat: Heat level of the weapon where 1 is normal and 0 is overheated.
  • type: Type of the weapon.
  • dtype: Damage type of the weapon.
  • track: Tracking level of the weapon.

An example would be:

ws_name, ws = p:weapset( true )
print( "Weapnset Name: " .. ws_name )
for i, w in ipairs(ws) do
print( "Name: " .. w.name )
print( "Cooldown: " .. tostring(w.cooldown) )
end

Lua usage parameter: set_name, slots = p:weapset() – Gets info for all active weapons Lua usage parameter: set_name, slots = p:weapset( 5 ) – Get info about the set number 5

Lua function parameter: Pilot p Pilot to get weapset weapon of. Lua function parameter:[opt=all] number id ID of the set to get information of. Defaults to currently active set. Lua return parameter: string The name of the set. Lua return parameter: table A table with each slot's information.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapset

Definition at line 1976 of file nlua_pilot.c.

◆ pilotL_weapsetAdd()

int pilotL_weapsetAdd ( lua_State * L)
static

Adds an outfit to a pilot's weapon set.

Lua function parameter: Pilot p Pilot to remove weapon from weapon set. Lua function parameter: integer id ID of the weapon set as shown in game (from 0 to 9). Lua function parameter: string|integer slot Slot to add to weapon set. Can be passed by either id or name.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetAdd

Definition at line 2108 of file nlua_pilot.c.

◆ pilotL_weapsetAddType()

int pilotL_weapsetAddType ( lua_State * L)
static

Adds an outfit to a pilot's weapon set.

Lua function parameter: Pilot p Pilot to remove weapon from weapon set. Lua function parameter: integer id ID of the weapon set as shown in game (from 0 to 9). Lua function parameter: string|integer slot Slot to add to weapon set. Can be passed by either id or name.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetAdd

Definition at line 2126 of file nlua_pilot.c.

◆ pilotL_weapsetAmmo()

int pilotL_weapsetAmmo ( lua_State * L)
static

Gets the ammo left of a weapon set.

Lua function parameter: Pilot p Pilot to get weapon set ammo for. Lua function parameter:[opt] number id Optional parameter indicating id of weapon set to get ammo of. Lua function parameter: number level Level of weapon set to get range of. Lua return parameter: number The range of the weapon set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetAmmo

Definition at line 2294 of file nlua_pilot.c.

◆ pilotL_weapsetAuto()

int pilotL_weapsetAuto ( lua_State * L)
static

Makes the pilot's weapons get automatically set.

Lua function parameter: Pilot p Pilot to automatically handle weapon sets for.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetAuto

Definition at line 2308 of file nlua_pilot.c.

◆ pilotL_weapsetCleanup()

int pilotL_weapsetCleanup ( lua_State * L)
static

Cleans up a weapon set. This removes all properties of the weapon set and resets it.

Lua function parameter: Pilot p Pilot to remove weapon from weapon set. Lua function parameter:[opt] integer id ID of the weapon set as shown in game (from 0 to 9). Cleans them all up if set to nil or not set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetCleanup

Definition at line 2170 of file nlua_pilot.c.

◆ pilotL_weapsetHeat()

int pilotL_weapsetHeat ( lua_State * L)
static

Gets heat information for a weapon set.

Heat is a 0-2 value that corresponds to three separate ranges:

  • 0: Weapon set isn't overheating and has no penalties.
  • 0-1: Weapon set has reduced accuracy.
  • 1-2: Weapon set has full accuracy penalty plus reduced fire rate.

Lua usage parameter: hmean, hpeak = p:weapsetHeat() – Gets info for all active weapons Lua usage parameter: hmean, hpeak = p:weapsetHeat( 5 ) – Get info about the set number 5

Lua function parameter: Pilot p Pilot to get weapset weapon of. Lua function parameter:[opt] number id ID of the set to get information of. Defaults to all weapon sets. Lua return parameter: number Mean heat. Lua return parameter: number Peak heat.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetHeat

Definition at line 2205 of file nlua_pilot.c.

◆ pilotL_weapsetList()

int pilotL_weapsetList ( lua_State * L)
static

Get a list of all the outfits in a weapon set.

Lua function parameter: Pilot p Pilot to set weapon set outfit list of. Lua function parameter: integer id ID of the weapon set as shown in game (from 0 to 9). Lua return parameter: table Table containing the slot ids of all outfits in the weapon set for use with functions such as pilot.outfitGet.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetList

Definition at line 2060 of file nlua_pilot.c.

◆ pilotL_weapsetRm()

int pilotL_weapsetRm ( lua_State * L)
static

Removes an outfit from a pilot's weapon set.

Lua function parameter: Pilot p Pilot to remove weapon from weapon set. Lua function parameter: integer id ID of the weapon set as shown in game (from 0 to 9). Lua function parameter: string|integer slot Slot to remove from weapon set. Can be passed by either id or name.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetRm

Definition at line 2152 of file nlua_pilot.c.

◆ pilotL_weapsetSetInrange()

int pilotL_weapsetSetInrange ( lua_State * L)
static

Sets whether a pilot's weapon set does inrange checks.

Lua function parameter: Pilot p Pilot to get weapset weapon of. Lua function parameter:[opt=nil] number id ID of the weapon set to set inrange check status, or nil for all. Lua function parameter: boolean docheck Whether or not to do inrange checks.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetSetInrange

Definition at line 2270 of file nlua_pilot.c.

◆ pilotL_weapsetType()

int pilotL_weapsetType ( lua_State * L)
static

Sets the type of a weapon set for a pilot.

Lua function parameter: Pilot p Pilot to set weapon set type of. Lua function parameter: integer id ID of the weapon set as shown in game (from 0 to 9). Lua function parameter: string type Type of the weapon set. Can be either "toggle", or "hold".

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapsetType

Definition at line 2083 of file nlua_pilot.c.

◆ pilotL_withPlayer()

int pilotL_withPlayer ( lua_State * L)
static

Checks to see if pilot is with player.

Lua function parameter: Pilot p Pilot to check to see if is with player. Lua return parameter: boolean true if pilot is with player.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: withPlayer

Definition at line 1653 of file nlua_pilot.c.

◆ pilotL_worth()

int pilotL_worth ( lua_State * L)
static

Gets the worth of a pilot (total value of ship and outfits).

Lua function parameter: Pilot p Pilot to get worth of. Lua function parameter:[opt=false] boolean count_unique Whether or not to count unique outfits too. Lua return parameter: number The credit worth of the pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: worth

Definition at line 5291 of file nlua_pilot.c.

◆ toggleSpawn()

void toggleSpawn ( int f,
int b )
static

Definition at line 973 of file nlua_pilot.c.

◆ weapsetItem()

int weapsetItem ( lua_State * L,
int * k,
Pilot * p,
const PilotOutfitSlot * slot,
const Pilot * target )
static

Sets up an item in a weapon set.

TODO move this to an object in its own module or something.

Definition at line 1781 of file nlua_pilot.c.

Variable Documentation

◆ cur_pilot

Pilot* cur_pilot
extern

Current pilot. All functions use this.

Definition at line 340 of file ai.c.

◆ pilotL_methods

const luaL_Reg pilotL_methods[]
static

Pilot metatable methods.

Definition at line 264 of file nlua_pilot.c.

◆ pL_flags

const struct pL_flag pL_flags[]
static

Flags to get.

Definition at line 5358 of file nlua_pilot.c.