Home

Module pilot

Lua bindings to interact with pilots. This will allow you to create and manipulate pilots in-game. An example would be:
 p = pilot.add( "Sml Trader Convoy" ) -- Create a trader convoy
 for k,v in pairs(p) do
 v:setFriendly() -- Make it friendly
 end
 

Functions

pilot.__eq (p, comp) Checks to see if pilot and p are the same.
pilot.actives (p) Gets the active outfits and their states of the pilot.
pilot.add (fleetname, ai, param) Adds a fleet to the system.
pilot.addOutfit (p, outfit, q, bypass) Adds an outfit to a pilot.
pilot.addRaw (shipname, ai, param, faction) Adds a ship with an AI and faction to the system (instead of a predefined fleet).
pilot.attack (p, pt) Makes the pilot attack another pilot.
pilot.brake (p) Makes the pilot brake.
pilot.broadcast (p, msg, ignore_int) Makes the pilot broadcast a message.
pilot.cargoAdd (p, type, quantity) Tries to add cargo to the pilot's ship.
pilot.cargoFree (p) Gets the free cargo space the pilot has.
pilot.cargoHas (p, type) Checks to see how many tons of a specific type of cargo the pilot has.
pilot.cargoList (p) Lists the cargo the pilot has.
pilot.cargoRm (p, type, quantity) Tries to remove cargo from the pilot's ship.
pilot.changeAI (p, newai) Changes the pilot's AI.
pilot.clear () Clears the current system of pilots.
pilot.colour (p) Gets the pilot's colour based on hostility or friendliness to the player.
pilot.comm (p, target, msg) Sends a message to the target or player if no target is passed.
pilot.control (p, enable) Sets manual control of the pilot.
pilot.cooldown (p) Gets a pilot's cooldown state.
pilot.dir (p) Gets the pilot's direction.
pilot.disable (p) Disables a pilot.
pilot.energy (p) Gets the pilot's energy.
pilot.ew (p) Gets the pilot's evasion.
pilot.exists (p) Checks to see if pilot is still in the system and alive.
pilot.face (p, target, towards) Makes the pilot face a target.
pilot.faction (p) Gets the pilot's faction.
pilot.flags (p) Gets the pilot's flags.
pilot.follow (p, pt, accurate) Makes the pilot follow another pilot.
pilot.get (factions, disabled) Gets the pilots available in the system by a certain criteria.
pilot.goto (p, v, brake, compensate) Makes the pilot goto a position.
pilot.hailPlayer (p, enable) Marks the pilot as hailing the player.
pilot.health (p) Gets the pilot's health.
pilot.hookClear (p) Clears the pilot's hooks.
pilot.hostile (p) Returns whether the pilot is hostile to the player.
pilot.hyperspace (p, sys, shoot) Tells the pilot to hyperspace.
pilot.id (p) Gets the ID of the pilot.
pilot.idle (p) Checks to see if the pilot is idle.
pilot.inrange (p, target) Checks to see if pilot is in range of pilot.
pilot.land (p, planet) Tells the pilot to land Pilot must be under manual control for this to work.
pilot.lockon (p) Gets the lockons on the pilot.
pilot.memory (p, key, value) Changes a parameter in the pilot's memory.
pilot.memoryCheck (p, str) Gets the value of the pilot's memory.
pilot.name (p) Gets the pilot's current name.
pilot.nav (p) Gets the nav target of the pilot.
pilot.outfits (p) Gets the outfits of a pilot.
pilot.pos (p) Gets the pilot's position.
pilot.rename (p, name) Changes the pilot's name.
pilot.rm (p) Removes a pilot without explosions or anything.
pilot.rmOutfit (p, outfit, q) Removes an outfit from a pilot.
pilot.runaway (p, tp, nojump) Makes the pilot runaway from another pilot.
pilot.setActiveBoard (p, state) Allows the pilot to be boarded when not disabled.
pilot.setCooldown (p, state) Starts or stops a pilot's cooldown mode.
pilot.setDir (p, dir) Sets the pilot's direction.
pilot.setEnergy (p, energy) Sets the energy of a pilot.
pilot.setFaction (p, faction) Sets the pilot's faction.
pilot.setFriendly (p, state) Controls the pilot's friendliness towards the player.
pilot.setFuel (p, f) Sets the fuel of a pilot.
pilot.setHealth (p, armour, shield, stress) Sets the health of a pilot.
pilot.setHilight (p, state) Makes pilot stand out on radar and the likes.
pilot.setHostile (p, state) Controls the pilot's hostility towards the player.
pilot.setInvincPlayer (p, state) Sets the pilot's invincibility status towards the player.
pilot.setInvincible (p, state) Sets the pilot's invincibility status.
pilot.setInvisible (p, state) Sets the pilot's invisibility status.
pilot.setNoDeath (p, state) Makes it so the pilot never dies, stays at 1.
pilot.setNoJump (p, state) Enables or disables a pilot's hyperspace engine.
pilot.setNoLand (p, state) Enables or disables landing for a pilot.
pilot.setNoboard (p, noboard) Sets the ability to board the pilot.
pilot.setNodisable (p, disable) Sets the ability of the pilot to be disabled.
pilot.setPos (p, pos) Sets the pilot's position.
pilot.setSpeedLimit (p, speed) Limits the speed of a pilot.
pilot.setTemp (p, temp, slots) Sets the temperature of a pilot.
pilot.setVel (p, vel) Sets the pilot's velocity.
pilot.setVisible (p, state) Marks the pilot as always visible for other pilots.
pilot.setVisplayer (p, state) Marks the pilot as always visible for the player.
pilot.ship (p) Gets the pilot's ship.
pilot.spaceworthy (p) Checks the pilot's spaceworthiness
pilot.stats (p) Gets stats of the pilot.
pilot.target (p) Gets the pilot target of the pilot.
pilot.taskClear (p) Clears all the tasks of the pilot.
pilot.temp (p) Gets the temperature of a pilot.
pilot.toggleSpawn (fid, enable) Disables or enables pilot spawning in the current system.
pilot.vel (p) Gets the pilot's velocity.
pilot.weapset (p, id) Gets the weapset weapon of the pilot.
pilot.weapsetHeat (p, id) Gets heat information for a weapon set.


Functions

pilot.__eq (p, comp)
Checks to see if pilot and p are the same.

Parameters

  • p: Pilot to compare.
  • comp: Pilot to compare against.

Usage:

if p == p2 then -- Pilot 'p' and 'p2' match.

Return value:

true if they are the same.
pilot.actives (p)
Gets the active outfits and their states of the pilot. The active outfits have the following structure:
  • name: Name of the set.
  • type: Type of the outfit.
  • temp: The heat of the outfit's slot. A value between 0 and 1, where 1 is fully overheated.
  • 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 _,o in ipairs(act_outfits) do
 print( "Name: " .. o.name )
 print( "State: " .. o.state )
 end
 

Parameters

  • p: Pilot to get active outfits of.

Usage:

act_outfits = p:actives() -- Gets the table of active outfits

Return value:

The table with each active outfit's information.
pilot.add (fleetname, ai, param)
Adds a fleet to the system. You can then iterate over the pilots to change parameters like so:
 p = pilot.add( "Sml Trader Convoy" )
 for k,v in pairs(p) do
 v:setHostile()
 end
 
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 planets
- planet: pilot takes off from the planet
- 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

Parameters

  • fleetname: Name of the fleet to add.
  • ai: If set will override the standard fleet AI. nil means use default.
  • param: Position to create pilot at, if it's a system it'll try to jump in from that system, if it's a planet it'll try to take off from it.

Usage

  • p = pilot.add( "Pirate Hyena" ) -- Just adds the pilot (will jump in or take off).
  • p = pilot.add( "Trader Llama", "dummy" ) -- Overrides AI with dummy ai.
  • p = pilot.add( "Sml Trader Convoy", nil, vec2.new( 1000, 200 ) ) -- Pilot won't jump in, will just appear.
  • p = pilot.add( "Empire Pacifier", nil, system.get("Goddard") ) -- Have the pilot jump in from the system.
  • p = pilot.add( "Goddard Goddard", nil, planet.get("Zhiru") ) -- Have the pilot take off from a planet.

Return value:

Table populated with all the pilots created. The keys are ordered numbers.
pilot.addOutfit (p, outfit, q, bypass)
Adds an outfit to a pilot. This by default tries to add them to the first empty or defaultly equipped slot.

Parameters

  • p: Pilot to add outfit to.
  • outfit: Name of the outfit to add.
  • q: Amount of the outfit to add (defaults to 1).
  • bypass: Whether to skip CPU and slot size checks before adding an outfit (defaults to false). Will not overwrite existing non-default outfits.

Usage:

added = p:addOutfit( "Laser Cannon", 5 ) -- Adds 5 laser cannons to p

Return value:

The number of outfits added.
pilot.addRaw (shipname, ai, param, faction)
Adds a ship with an AI and faction to the system (instead of a predefined fleet).

Parameters

  • shipname: Name of the ship to add.
  • ai: AI to give the pilot.
  • param: Position to create the pilot at. See pilot.add for further information.
  • faction: Faction to give the pilot.

Usage:

p = pilot.addRaw( "Empire Shark", "empire", nil, "Empire" ) -- Creates a pilot analogous to the Empire Shark fleet.

Return value:

Table populated with the created pilot.
pilot.attack (p, pt)
Makes the pilot attack another pilot. Pilot must be under manual control for this to work.

Parameters

  • p: Pilot to tell to attack another pilot.
  • pt: Target pilot to attack (or nil to attack nearest enemy).

Usage

  • p:attack( another_pilot ) -- Attack another pilot
  • p:attack() -- Attack nearest pilot.

See also:

pilot.brake (p)
Makes the pilot brake. Pilot must be under manual control for this to work.

Parameters

  • p: Pilot to tell to brake.

See also:

pilot.broadcast (p, msg, ignore_int)
Makes the pilot broadcast a message.

Parameters

  • p: Pilot to broadcast the message.
  • msg: Message to broadcast.
  • ignore_int: Whether or not it should ignore interference.

Usage

  • p:broadcast( "Mayday! Requesting assistance!" )
  • p:broadcast( "Help!", true ) -- Will ignore interference
pilot.cargoAdd (p, type, quantity)
Tries to add cargo to the pilot's ship.

Parameters

  • p: The pilot to add cargo to.
  • type: Name of the cargo to add.
  • quantity: Quantity of cargo to add.

Usage:

n = pilot.cargoAdd( player.pilot(), "Food", 20 )

Return value:

The quantity of cargo added.
pilot.cargoFree (p)
Gets the free cargo space the pilot has.

Parameters

  • p: The pilot to get the free cargo space of.

Return value:

The free cargo space in tons of the player.
pilot.cargoHas (p, type)
Checks to see how many tons of a specific type of cargo the pilot has.

Parameters

  • p: The pilot to get the cargo count of.
  • type: Type of cargo to count.

Return value:

The amount of cargo the player has.
pilot.cargoList (p)
Lists the cargo the pilot has. The list has the following members:
  • name: name of the cargo.
  • q: quantity of the cargo.
  • m: true if cargo is for a mission.

Parameters

  • p: Pilot to list cargo of.

Usage:

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

Return value:

An ordered list with the names of the cargo the pilot has.
pilot.cargoRm (p, type, quantity)
Tries to remove cargo from the pilot's ship.

Parameters

  • p: The pilot to remove cargo from.
  • type: Name of the cargo to remove.
  • quantity: Quantity of the cargo to remove.

Usage:

n = pilot.cargoRm( player.pilot(), "Food", 20 )

Return value:

The number of cargo removed.
pilot.changeAI (p, newai)
Changes the pilot's AI.

Parameters

  • p:
  • newai:

Usage:

p:changeAI( "empire" ) -- set the pilot to use the Empire AI
pilot.clear ()
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.

Usage:

pilot.clear()
pilot.colour (p)
Gets the pilot's colour based on hostility or friendliness to the player.

Parameters

  • p: Pilot to get the colour of.

Usage:

p:colour()

Return value:

The pilot's colour.
pilot.comm (p, target, msg)
Sends a message to the target or player if no target is passed.

Parameters

  • p: Pilot to message the player.
  • target:
  • msg: Message to send.

Usage

  • p:comm( "How are you doing?" ) -- Messages the player
  • p:comm( "You got this?", true ) -- Messages the player ignoring interference
  • p:comm( target, "Heya!" ) -- Messages target
  • p:comm( target, "Got this?", true ) -- Messages target ignoring interference
pilot.control (p, enable)
Sets manual control of the pilot.

Parameters

  • p: Pilot to change manual control settings.
  • enable: If true or nil enables pilot manual control, otherwise enables automatic AI.

Usage

  • p:control() -- Same as p:control(true), enables manual control of the pilot
  • p:control(false) -- Restarts AI control of the pilot

See also:

pilot.cooldown (p)
Gets a pilot's cooldown state.

Parameters

  • p: Pilot to check the cooldown status of.

Usage:

cooldown, braking = p:cooldown()

Return value:

Cooldown and cooldown braking status.
pilot.dir (p)
Gets the pilot's direction.

Parameters

  • p: Pilot to get the direction of.

Usage:

d = p:dir()

Return value:

The pilot's current direction as a number (in degrees).
pilot.disable (p)
Disables a pilot.

Parameters

  • p: Pilot to disable.

Usage:

p:disable()
pilot.energy (p)
Gets the pilot's energy.

Parameters

  • p: Pilot to get energy of.

Usage:

energy = p:energy()

Return value:

The energy of the pilot in % [0:100].
pilot.ew (p)
Gets the pilot's evasion.

Parameters

  • p: Pilot to get the evasion of.

Usage:

d = p:ew()

Return value:

The pilot's current evasion value.
pilot.exists (p)
Checks to see if pilot is still in the system and alive. Pilots cease to exist if they die or jump out.

Parameters

  • p: Pilot to check to see if is still exists.

Usage:

if p:exists() then -- Pilot still exists

Return value:

true if pilot is still exists.
pilot.face (p, target, towards)
Makes the pilot face a target.

Parameters

  • p: Pilot to add task to.
  • target: Target to face (can be vec2 or pilot).
  • towards: Optional parameter that makes the task end when the target is faced (otherwise it's an enduring state).

Usage

  • p:face( enemy_pilot ) -- Face enemy pilot
  • p:face( vec2.new( 0, 0 ) ) -- Face origin
  • p:face( enemy_pilot, true ) -- Task lasts until the enemy pilot is faced
pilot.faction (p)
Gets the pilot's faction.

Parameters

  • p: Pilot to get the faction of.

Usage:

f = p:faction()

Return value:

The faction of the pilot.
pilot.flags (p)
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.
  • 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.
  • takingoff: pilot is currently taking off.
  • manualcontrol: pilot is under manual control.

Parameters

  • p: Pilot to get flags of.

Return value:

Table with flag names an index, boolean as value.
pilot.follow (p, pt, accurate)
Makes the pilot follow another pilot. Pilot must be under manual control for this to work.

Parameters

  • p: Pilot to tell to follow another pilot.
  • pt: Target pilot to follow.
  • accurate: If true, use a PD controller which

See also:

pilot.get (factions, disabled)
Gets the pilots available in the system by a certain criteria.

Parameters

  • factions: If f is a table of factions, it will only get pilots matching those factions. Otherwise it gets all the pilots.
  • disabled: Whether or not to get disabled ships (default is off if parameter is omitted).

Usage

  • p = pilot.get() -- Gets all the pilots
  • p = pilot.get( { faction.get("Empire") } ) -- Only gets empire pilots.
  • p = pilot.get( nil, true ) -- Gets all pilots including disabled
  • p = pilot.get( { faction.get("Empire") }, true ) -- Only empire pilots with disabled

Return value:

A table containing the pilots.
pilot.goto (p, v, brake, compensate)
Makes the pilot goto a position. Pilot must be under manual control for this to work.

Parameters

  • p: Pilot to tell to go to a position.
  • v: Vector target for the pilot.
  • brake: If true (or nil) brakes the pilot near target position, otherwise pops the task when it is about to brake.
  • compensate: If true (or nil) compensates for velocity, otherwise it doesn't. It only affects if brake is not set.

Usage

  • p:goto( v ) -- Goes to v precisely and braking
  • p:goto( v, true, true ) -- Same as p:goto( v )
  • p:goto( v, false ) -- Goes to v without braking compensating velocity
  • p:goto( v, false, false ) -- Really rough approximation of going to v without braking

See also:

pilot.hailPlayer (p, enable)
Marks the pilot as hailing the player. Automatically deactivated when pilot is hailed.

Parameters

  • p: Pilot to hail the player.
  • enable: If true hails the pilot, if false disables the hailing. Defaults to true.

Usage:

p:hailPlayer() -- Player will be informed he's being hailed and pilot will have an icon
pilot.health (p)
Gets the pilot's health.

Parameters

  • p: Pilot to get health of.

Usage:

armour, shield, stress, dis = p:health()

Return value:

The armour, shield and stress of the pilot in % [0:100], followed by a boolean indicating if pilot is disabled.
pilot.hookClear (p)
Clears the pilot's hooks. Clears all the hooks set on the pilot.

Parameters

  • p: Pilot to clear hooks.

Usage:

p:hookClear()
pilot.hostile (p)
Returns whether the pilot is hostile to the player.

Parameters

  • p: Pilot to get the hostility of.

Usage:

p:hostile()

Return value:

The pilot's hostility status.
pilot.hyperspace (p, sys, shoot)
Tells the pilot to hyperspace. Pilot must be under manual control for this to work.

Parameters

  • p: Pilot to tell to hyperspace.
  • sys: Optional system argument to jump to, uses random if nil.
  • shoot: Optional whether or not to shoot at targets while running away with turrets.

See also:

pilot.id (p)
Gets the ID of the pilot.

Parameters

  • p: Pilot to get the ID of.

Usage:

id = p:id()

Return value:

The ID of the current pilot.
pilot.idle (p)
Checks to see if the pilot is idle.

Parameters

  • p: Pilot to check to see if is idle.

Usage:

idle = p:idle() -- Returns true if the pilot is idle

Return value:

true if pilot is idle, false otherwise
pilot.inrange (p, target)
Checks to see if pilot is in range of pilot.

Parameters

  • p: Pilot to see if another pilot is in range.
  • target:

Usage:

detected, scanned = p:inrange( target )

Return value:

Checks to see if the target is detected and if it's scanned.
pilot.land (p, planet)
Tells the pilot to land Pilot must be under manual control for this to work.

Parameters

  • p: Pilot to tell to land.
  • planet: Optional planet to land on, uses random if nil.

See also:

pilot.lockon (p)
Gets the lockons on the pilot.

Parameters

  • p: Pilot to get lockons of.

Usage:

lockon = p:lockon()

Return value:

The number of lockons on the pilot.
pilot.memory (p, key, value)
Changes a parameter in the pilot's memory.

Parameters

  • p: Pilot to change memory of.
  • key: Key of the memory part to change.
  • value: Value to set to.
pilot.memoryCheck (p, str)
Gets the value of the pilot's memory. Equivalent to reading the pilot's "mem.str".

Parameters

  • p: Pilot to get memory of.
  • str: Name of the memory to get.

Usage:

aggr = p:memoryCheck( "aggressive" ) -- See if the pilot is aggressive

Return value:

The value stored.
pilot.name (p)
Gets the pilot's current name.

Parameters

  • p: Pilot to get the name of.

Usage:

name = p:name()

Return value:

The current name of the pilot.
pilot.nav (p)
Gets the nav target of the pilot. This will only terminate when the target following pilot disappears (land, death, jump, etc...).

Parameters

  • p: Pilot to get nav info of.

Usage:

planet, hyperspace = p:nav()

Return value:

The planet target followed by the hyperspace target or nil if not targeted.
pilot.outfits (p)
Gets the outfits of a pilot.

Parameters

  • p: Pilot to get outfits of.

Return value:

The outfits of the pilot in an ordered list.
pilot.pos (p)
Gets the pilot's position.

Parameters

  • p: Pilot to get the position of.

Usage:

v = p:pos()

Return value:

The pilot's current position as a vec2.
pilot.rename (p, name)
Changes the pilot's name.

Parameters

  • p: Pilot to change name of.
  • name: Name to change to.

Usage:

p:rename( "Black Beard" )
pilot.rm (p)
Removes a pilot without explosions or anything.

Parameters

  • p: Pilot to remove.

Usage:

p:rm() -- pilot will be destroyed
pilot.rmOutfit (p, outfit, q)
Removes an outfit from a pilot. "all" will remove all outfits except cores. "cores" will remove all cores, but nothing else.

Parameters

  • p: Pilot to remove outfit from.
  • outfit: Name of the outfit to remove.
  • q: Quantity of the outfit to remove.

Usage

  • p:rmOutfit( "all" ) -- Leaves the pilot naked (except for cores).
  • p:rmOutfit( "cores" ) -- Strips the pilot of its cores, leaving it dead in space.
  • p:rmOutfit( "Neutron Disruptor" ) -- Removes a neutron disruptor.
  • p:rmOutfit( "Neutron Disruptor", 2 ) -- Removes two neutron disruptor.

Return value:

The number of outfits removed.
pilot.runaway (p, tp, nojump)
Makes the pilot runaway from another pilot. By default the pilot tries to jump when running away.

Parameters

  • p: Pilot to tell to runaway from another pilot.
  • tp: Target pilot to runaway from.
  • nojump: Whether or not the pilot should try to jump when running away.

Usage

  • p:runaway( p_enemy ) -- Run away from p_enemy
  • p:runaway( p_enemy, true ) -- Run away from p_enemy but do not jump

See also:

pilot.setActiveBoard (p, state)
Allows the pilot to be boarded when not disabled.

Parameters

  • p: Pilot to set boardability of.
  • state: State to set boardability, defaults to true.

Usage:

p:setActiveBoard( true )
pilot.setCooldown (p, state)
Starts or stops a pilot's cooldown mode.

Parameters

  • p: Pilot to modify the cooldown status of.
  • state: Whether to enable or disable cooldown (defaults to true).

Usage:

p:setCooldown( true )
pilot.setDir (p, dir)
Sets the pilot's direction.

Parameters

  • p: Pilot to set the direction of.
  • dir: Direction to set.

Usage:

p:setDir( 180. )
pilot.setEnergy (p, energy)
Sets the energy of a pilot.

Parameters

  • p: Pilot to set energy of.
  • energy: Value to set energy to, should be double from 0-100 (in percent).

Usage

  • p:setEnergy( 100 ) -- Sets pilot to full energy.
  • p:setEnergy( 70 ) -- Sets pilot to 70% energy.
pilot.setFaction (p, faction)
Sets the pilot's faction.

Parameters

  • p: Pilot to change faction of.
  • faction: Faction to set by name or faction.

Usage

  • p:setFaction( "Empire" )
  • p:setFaction( faction.get( "Dvaered" ) )
pilot.setFriendly (p, state)
Controls the pilot's friendliness towards the player.

Parameters

  • p: Pilot to set the friendliness of.
  • state: Whether to set or unset friendly.

Usage

  • p:setFriendly() -- Pilot is now friendly.
  • p:setFriendly(false) -- Make pilot non-friendly.
pilot.setFuel (p, f)
Sets the fuel of a pilot.

Parameters

  • p: Pilot to set fuel of.
  • f: true sets fuel to max, false sets fuel to 0, a number sets fuel to that amount in units.

Usage:

p:setFuel( true ) -- Sets fuel to max

Return value:

The amount of fuel the pilot has.
pilot.setHealth (p, armour, shield, stress)
Sets the health of a pilot. This recovers the pilot's disabled state, although he may become disabled afterwards.

Parameters

  • p: Pilot to set health of.
  • armour: Value to set armour to, should be double from 0-100 (in percent).
  • shield: Value to set shield to, should be double from 0-100 (in percent).
  • stress: Optional value to set stress (disable damage) to, should be double from 0-100 (in percent of current armour). If missing, defaults to 0.

Usage

  • p:setHealth( 100, 100 ) -- Sets pilot to full health
  • p:setHealth( 70, 0 ) -- Sets pilot to 70% armour
  • p:setHealth( 100, 100, 0 ) -- Sets pilot to full health and no stress
pilot.setHilight (p, state)
Makes pilot stand out on radar and the likes. This makes the pilot stand out in the map overlay and radar to increase noticability.

Parameters

  • p: Pilot to set hilight status of.
  • state: State to set hilight, defaults to true.

Usage:

p:setHilight( true )
pilot.setHostile (p, state)
Controls the pilot's hostility towards the player.

Parameters

  • p: Pilot to set the hostility of.
  • state: Whether to set or unset hostile.

Usage

  • p:setHostile() -- Pilot is now hostile.
  • p:setHostile(false) -- Make pilot non-hostile.
pilot.setInvincPlayer (p, state)
Sets the pilot's invincibility status towards the player.

Parameters

  • p: Pilot to set invincibility status of (only affects player).
  • state: State to set invincibility, if omitted defaults to true.

Usage

  • p:setInvincPlayer() -- p can not be hit by the player anymore
  • p:setInvincPlayer(true) -- p can not be hit by the player anymore
  • p:setInvincPlayer(false) -- p can be hit by the player again
pilot.setInvincible (p, state)
Sets the pilot's invincibility status.

Parameters

  • p: Pilot to set invincibility status of.
  • state: State to set invincibility, if omitted defaults to true.

Usage

  • p:setInvincible() -- p can not be hit anymore
  • p:setInvincible(true) -- p can not be hit anymore
  • p:setInvincible(false) -- p can be hit again
pilot.setInvisible (p, state)
Sets the pilot's invisibility status. An invisible pilot is neither updated nor drawn. It stays frozen in time until the invisibility is lifted.

Parameters

  • p: Pilot to set invisibility status of.
  • state: State to set invisibility, if omitted defaults to true.

Usage

  • p:setInvisible() -- p will disappear
  • p:setInvisible(true) -- p will disappear
  • p:setInvisible(false) -- p will appear again
pilot.setNoDeath (p, state)
Makes it so the pilot never dies, stays at 1. armour.

Parameters

  • p: Pilot to set never die state of.
  • state: Whether or not to set never die state.

Usage:

p:setNoDeath( true ) -- Pilot will never die
pilot.setNoJump (p, state)
Enables or disables a pilot's hyperspace engine.

Parameters

  • p: Pilot to modify.
  • state:

Usage:

p:setNoJump( true )
pilot.setNoLand (p, state)
Enables or disables landing for a pilot.

Parameters

  • p: Pilot to modify.
  • state:

Usage:

p:setNoLand( true )
pilot.setNoboard (p, noboard)
Sets the ability to board the pilot. No parameter is equivalent to true.

Parameters

  • p: Pilot to set disable boarding.
  • noboard: If true it disallows boarding of the pilot, otherwise it allows boarding which is the default.

Usage:

p:setNoboard( true ) -- Pilot can not be boarded by anyone
pilot.setNodisable (p, disable)
Sets the ability of the pilot to be disabled. No parameter is equivalent to true.

Parameters

  • p: Pilot to set disable disabling.
  • disable: If true it disallows disabled of the pilot, otherwise it allows disabling which is the default.

Usage:

p:setNodisable( true ) -- Pilot can not be disabled anymore.
pilot.setPos (p, pos)
Sets the pilot's position.

Parameters

  • p: Pilot to set the position of.
  • pos: Position to set.

Usage:

p:setPos( vec2.new( 300, 200 ) )
pilot.setSpeedLimit (p, speed)
Limits the speed of a pilot.

Parameters

  • p: Pilot to set speed of.
  • speed: Value to set speed to.

Usage

  • p:setSpeedLimit( 100 ) -- Sets maximumspeed to 100px/s.
  • p:setSpeedLimit( 0 ) removes speed limit.
pilot.setTemp (p, temp, slots)
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.

Parameters

  • p: Pilot to set health of.
  • temp: Value to set temperature to. Values below base temperature will be clamped.
  • slots: Whether slots should also be set to this temperature. Defaults to true.

Usage

  • p:setTemp( 300, true ) -- Sets ship temperature to 300K, as well as all outfits.
  • p:setTemp( 500, false ) -- Sets ship temperature to 500K, but leaves outfits alone.
  • p:setTemp( 0 ) -- Sets ship temperature to the base temperature, as well as all outfits.
pilot.setVel (p, vel)
Sets the pilot's velocity.

Parameters

  • p: Pilot to set the velocity of.
  • vel: Velocity to set.

Usage:

p:setVel( vec2.new( 300, 200 ) )
pilot.setVisible (p, state)
Marks the pilot as always visible for other pilots. This cancels out ewarfare visibility ranges and affects every pilot.

Parameters

  • p: Pilot to set visibility status of.
  • state: State to set visibility, defaults to true.

Usage:

p:setVisible( true )
pilot.setVisplayer (p, state)
Marks the pilot as always visible for the player. This cancels out ewarfare visibility ranges and only affects the visibility of the player.

Parameters

  • p: Pilot to set player visibility status of.
  • state: State to set player visibility, defaults to true.

Usage:

p:setVisplayer( true )
pilot.ship (p)
Gets the pilot's ship.

Parameters

  • p: Pilot to get ship of.

Usage:

s = p:ship()

Return value:

The ship of the pilot.
pilot.spaceworthy (p)
Checks the pilot's spaceworthiness

Parameters

  • p: Pilot to get the spaceworthy status of

Usage:

spaceworthy = p:spaceworthy()

Return value:

Whether the pilot's ship is spaceworthy
pilot.stats (p)
Gets stats of the pilot. Some of the stats are:
  • cpu
  • cpu_max
  • crew
  • fuel
  • fuel_max
  • fuel_consumption
  • mass
  • thrust
  • speed
  • speed_max
  • turn
  • absorb
  • armour
  • shield
  • energy
  • armour_regen
  • shield_regen
  • energy_regen
  • jump_delay
  • jumps

Parameters

  • p: Pilot to get stats of.

Usage:

stats = p:stats() print(stats.armour)

Return value:

A table containing the stats of p.
pilot.target (p)
Gets the pilot target of the pilot.

Parameters

  • p: Pilot to get target of.

Usage:

target = p:target()

Return value:

nil if no target is selected, otherwise the target of the target.
pilot.taskClear (p)
Clears all the tasks of the pilot.

Parameters

  • p: Pilot to clear tasks of.

Usage:

p:taskClear()
pilot.temp (p)
Gets the temperature of a pilot.

Parameters

  • p: Pilot to get temperature of.

Usage:

t = p:temp()

Return value:

The pilot's current temperature (in kelvin).
pilot.toggleSpawn (fid, enable)
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.

Parameters

  • fid: Faction to enable or disable spawning off. If ommited it works on global spawning.
  • enable: true enables spawn, false disables it.

Usage

  • pilot.toggleSpawn() -- Defaults to flipping the global spawning (true->false and false->true)
  • pilot.toggleSpawn( false ) -- Disables global spawning
  • pliot.toggleSpawn( "Pirates" ) -- Defaults to disabling pirate spawning
  • pilot.toggleSpawn( "Pirates", true ) -- Turns on pirate spawning

Return value:

The current spawn state.
pilot.vel (p)
Gets the pilot's velocity.

Parameters

  • p: Pilot to get the velocity of.

Usage:

vel = p:vel()

Return value:

The pilot's current velocity as a vec2.
pilot.weapset (p, id)
Gets the weapset weapon of the pilot. The weapon sets have the following structure:
  • name: name of the set.
  • cooldown: [0:1] value indicating if ready to shoot (1 is ready).
  • charge: [0:1] charge level of beam weapon (1 is full).
  • ammo: Name of the ammo or nil if not applicable.
  • left: Absolute ammo left or nil if not applicable.
  • left_p: Relative ammo left [0:1] or nil if not applicable
  • lockon: Lockon [0:1] for seeker weapons or nil if not applicable.
  • in_arc: Whether or not the target is in targetting arc or nil if not applicable.
  • level: Level of the weapon (1 is primary, 2 is secondary).
  • temp: Temperature of the weapon.
  • 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 _,w in ipairs(ws) do
 print( "Name: " .. w.name )
 print( "Cooldown: " .. tostring(cooldown) )
 print( "Level: " .. tostring(level) )
 end
 

Parameters

  • p: Pilot to get weapset weapon of.
  • id: ID of the set to get information of. Defaults to currently active set.

Usage

  • set_name, slots = p:weapset( true ) -- Gets info for all active weapons
  • set_name, slots = p:weapset() -- Get info about the current set
  • set_name, slots = p:weapset( 5 ) -- Get info about the set number 5

Return value:

The name of the set and a table with each slot's information.
pilot.weapsetHeat (p, id)
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.

Parameters

  • p: Pilot to get weapset weapon of.
  • id: ID of the set to get information of. Defaults to currently active set.

Usage

  • hmean, hpeak = p:weapsetHeat( true ) -- Gets info for all active weapons
  • hmean, hpeak = p:weapsetHeat() -- Get info about the current set
  • hmean, hpeak = p:weapsetHeat( 5 ) -- Get info about the set number 5

Return value:

The name of the set and a table with each slot's information.

Valid XHTML 1.0!