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

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


Functions

choosePoint (f, i, g)
Returns a suitable jumpin spot for a given pilot. ( f, i )

Parameters:

  • f Faction Faction the pilot will belong to.
  • i boolean Wether to ignore rules.
  • g boolean Wether to behave as guerilla (spawn in deep space)

Returns:

    Planet, Vec2 or Jump A randomly chosen suitable spawn point.

Usage:

    point = pilot.choosePoint( f, i, g )
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
( fleetname, ai, param )

Parameters:

  • fleetname string Name of the fleet to add.
  • ai string or nil If set will override the standard fleet AI. nil means use default. (optional)
  • param System or Planet 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.

Returns:

    {Pilot,...} Table populated with all the pilots created. The keys are ordered numbers.

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.
addRaw (shipname, ai, param, faction)
Adds a ship with an AI and faction to the system (instead of a predefined fleet). ( shipname, ai, param, faction )

Parameters:

  • shipname string Name of the ship to add.
  • ai string or nil AI to give the pilot.
  • param System or Planet Position to create the pilot at. See pilot.add for further information.
  • faction Faction Faction to give the pilot.

Returns:

    Pilot The created pilot.

Usage:

    p = pilot.addRaw( "Empire Shark", "empire", nil, "Empire" ) -- Creates a pilot analogous to the Empire Shark fleet.
rm (p)
Removes a pilot without explosions or anything. ( p )

Parameters:

  • p Pilot Pilot to remove.

Usage:

    p:rm() -- pilot will be destroyed
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()
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. ( fid, enable )

Parameters:

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

Returns:

    boolean The current spawn state.

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
get (factions, disabled)
Gets the pilots available in the system by a certain criteria. ( factions, disabled )

Parameters:

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

Returns:

    {Pilot,...} A table containing the pilots.

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
__eq (p, comp)
Checks to see if pilot and p are the same. ( p, comp )

Parameters:

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

Returns:

    boolean true if they are the same.

Usage:

    if p == p2 then -- Pilot 'p' and 'p2' match.
name (p)
Gets the pilot's current name. ( p )

Parameters:

  • p Pilot Pilot to get the name of.

Returns:

    string The current name of the pilot.

Usage:

    name = p:name()
id (p)
Gets the ID of the pilot. ( p )

Parameters:

  • p Pilot Pilot to get the ID of.

Returns:

    number The ID of the current pilot.

Usage:

    id = p:id()
exists (p)
Checks to see if pilot is still in the system and alive.

Pilots cease to exist if they die or jump out. ( p )

Parameters:

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

Returns:

    boolean true if pilot is still exists.

Usage:

    if p:exists() then -- Pilot still exists
target (p)
Gets the pilot target of the pilot. ( p )

Parameters:

  • p Pilot Pilot to get target of.

Returns:

    Pilot or nil nil if no target is selected, otherwise the target of the pilot.

Usage:

    target = p:target()
inrange (p, target)
Checks to see if pilot is in range of pilot. ( p, target )

Parameters:

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

Returns:

    boolean Checks to see if the target is detected and if it's scanned.

Usage:

    detected, scanned = p:inrange( target )
nav (p)
Gets the nav target of the pilot.

This will only terminate when the target following pilot disappears (land, death, jump, etc...). ( p )

Parameters:

  • p Pilot Pilot to get nav info of.

Returns:

  1. Planet or nil The pilot's planet target.
  2. System or nil The pilot's hyperspace target.

Usage:

    planet, hyperspace = p:nav()
activeWeapset (p, current)
Gets the ID (number from 1 to 10) of the current active weapset. ( p, number )

Parameters:

  • p Pilot Pilot to get active weapset ID of.
  • current number active weapset ID.

Usage:

    set_id = p:activeWeapset() -- A number from 1 to 10
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
 
( p, id)

Parameters:

  • p Pilot Pilot to get weapset weapon of.
  • id number ID of the set to get information of. Defaults to currently active set. (optional)

Returns:

  1. string The name of the set.
  2. table A table with each slot's information.

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
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.
(p, id)

Parameters:

  • p Pilot Pilot to get weapset weapon of.
  • id number ID of the set to get information of. Defaults to currently active set. (optional)

Returns:

  1. number Mean heat.
  2. number Peak heat.

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
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
 
( p )

Parameters:

  • p Pilot Pilot to get active outfits of.

Returns:

    table The table with each active outfit's information.

Usage:

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

Parameters:

  • p Pilot Pilot to get outfits of.

Returns:

    table The outfits of the pilot in an ordered list.
rename (p, name)
Changes the pilot's name. ( p, name )

Parameters:

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

Usage:

    p:rename( "Black Beard" )
pos (p)
Gets the pilot's position. ( p )

Parameters:

  • p Pilot Pilot to get the position of.

Returns:

    Vec2 The pilot's current position.

Usage:

    v = p:pos()
vel (p)
Gets the pilot's velocity. ( p )

Parameters:

  • p Pilot Pilot to get the velocity of.

Returns:

    Vec2 The pilot's current velocity.

Usage:

    vel = p:vel()
ew (p)
Gets the pilot's evasion. ( p )

Parameters:

  • p Pilot Pilot to get the evasion of.

Returns:

    number The pilot's current evasion value.

Usage:

    d = p:ew()
dir (p)
Gets the pilot's direction. ( p )

Parameters:

  • p Pilot Pilot to get the direction of.

Returns:

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

Usage:

    d = p:dir()
temp (p)
Gets the temperature of a pilot. ( p )

Parameters:

  • p Pilot Pilot to get temperature of.

Returns:

    number The pilot's current temperature (in kelvin).

Usage:

    t = p:temp()
faction (p)
Gets the pilot's faction. ( p )

Parameters:

  • p Pilot Pilot to get the faction of.

Returns:

    Faction The faction of the pilot.

Usage:

    f = p:faction()
spaceworthy (p)
Checks the pilot's spaceworthiness ( p )

Parameters:

  • p Pilot Pilot to get the spaceworthy status of

Returns:

    boolean Whether the pilot's ship is spaceworthy

Usage:

    spaceworthy = p:spaceworthy()
setPos (p, pos)
Sets the pilot's position. ( p, pos )

Parameters:

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

Usage:

    p:setPos( vec2.new( 300, 200 ) )
setVel (p, vel)
Sets the pilot's velocity. ( p, vel )

Parameters:

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

Usage:

    p:setVel( vec2.new( 300, 200 ) )
setDir (p, dir)
Sets the pilot's direction.

( p, dir )

Parameters:

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

Usage:

    p:setDir( 180. )
broadcast (p, msg[, ignore_int=false])
Makes the pilot broadcast a message. ( p, msg, ignore_int )

Parameters:

  • p Pilot Pilot to broadcast the message.
  • msg string Message to broadcast.
  • ignore_int boolean Whether or not it should ignore interference. (default false)

Usage:

  • p:broadcast( "Mayday! Requesting assistance!" )
  • p:broadcast( "Help!", true ) -- Will ignore interference
comm (p, target, msg[, ignore_int=false])
Sends a message to the target or player if no target is passed. ( p, target, msg, ignore_int )

Parameters:

  • p Pilot Pilot to message the player.
  • target Pilot Target to send message to.
  • msg string Message to send.
  • ignore_int boolean Whether or not it should ignore interference. (default false)

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
setFaction (p, faction)
Sets the pilot's faction. ( p, faction )

Parameters:

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

Usage:

  • p:setFaction( "Empire" )
  • p:setFaction( faction.get( "Dvaered" ) )
setHostile (p[, state=true])
Controls the pilot's hostility towards the player. ( p, state )

Parameters:

  • p Pilot Pilot to set the hostility of.
  • state boolean Whether to set or unset hostile. (default true)

Usage:

  • p:setHostile() -- Pilot is now hostile.
  • p:setHostile(false) -- Make pilot non-hostile.
setFriendly (p[, state=true])
Controls the pilot's friendliness towards the player. ( p, state )

Parameters:

  • p Pilot Pilot to set the friendliness of.
  • state boolean Whether to set or unset friendly. (default true)

Usage:

  • p:setFriendly() -- Pilot is now friendly.
  • p:setFriendly(false) -- Make pilot non-friendly.
setInvincible (p[, state=true])
Sets the pilot's invincibility status. ( p, state )

Parameters:

  • p Pilot Pilot to set invincibility status of.
  • state boolean State to set invincibility. (default 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
setInvincPlayer (p[, state=true])
Sets the pilot's invincibility status towards the player. ( p, state )

Parameters:

  • p Pilot Pilot to set invincibility status of (only affects player).
  • state boolean State to set invincibility. (default 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
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. ( p, state )

Parameters:

  • p Pilot Pilot to set invisibility status of.
  • state boolean State to set invisibility.

Usage:

  • p:setInvisible() -- p will disappear
  • p:setInvisible(true) -- p will disappear
  • p:setInvisible(false) -- p will appear again
setVisplayer (p[, state=true])
Marks the pilot as always visible for the player.

This cancels out ewarfare visibility ranges and only affects the visibility of the player. ( p, state )

Parameters:

  • p Pilot Pilot to set player visibility status of.
  • state boolean State to set player visibility. (default true)

Usage:

    p:setVisplayer( true )
setVisible (p[, state=true])
Marks the pilot as always visible for other pilots.

This cancels out ewarfare visibility ranges and affects every pilot. ( p, state )

Parameters:

  • p Pilot Pilot to set visibility status of.
  • state boolean State to set visibility. (default true)

Usage:

    p:setVisible( true )
setHilight (p[, state=true])
Makes pilot stand out on radar and the likes.

This makes the pilot stand out in the map overlay and radar to increase noticability. ( p, state )

Parameters:

  • p Pilot Pilot to set hilight status of.
  • state boolean State to set hilight. (default true)

Usage:

    p:setHilight( true )
setActiveBoard (p[, state=true])
Allows the pilot to be boarded when not disabled. ( p, state )

Parameters:

  • p Pilot Pilot to set boardability of.
  • state boolean State to set boardability. (default true)

Usage:

    p:setActiveBoard( true )
setNoDeath (p[, state=true])
Makes it so the pilot never dies, stays at 1. armour. ( p, state )

Parameters:

  • p Pilot Pilot to set never die state of.
  • state boolean Whether or not to set never die state. (default true)

Usage:

    p:setNoDeath( true ) -- Pilot will never die
disable (p)
Disables a pilot. ( p )

Parameters:

  • p Pilot Pilot to disable.

Usage:

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

Parameters:

  • p Pilot Pilot to check the cooldown status of.

Returns:

  1. boolean Cooldown status.
  2. boolean Cooldown braking status.

Usage:

    cooldown, braking = p:cooldown()
setCooldown (p[, state=true])
Starts or stops a pilot's cooldown mode. ( p, state )

Parameters:

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

Usage:

    p:setCooldown( true )
setNoJump (p[, state=true])
Enables or disables a pilot's hyperspace engine. ( p, state )

Parameters:

  • p Pilot Pilot to modify.
  • state boolean true or false (default true)

Usage:

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

Parameters:

  • p Pilot Pilot to modify.
  • state boolean true or false (optional)

Usage:

    p:setNoLand( true )
addOutfit (p, outfit[, q=1[, bypass=false]])
Adds an outfit to a pilot.

This by default tries to add them to the first empty or defaultly equipped slot. ( p, outfit, q, bypass )

Parameters:

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

Returns:

    number The number of outfits added.

Usage:

    added = p:addOutfit( "Laser Cannon", 5 ) -- Adds 5 laser cannons to p
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. ( p, outfit, q )

Parameters:

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

Returns:

    number The number of outfits removed.

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.
setFuel (p, f)
Sets the fuel of a pilot. ( p, f )

Parameters:

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

Returns:

    number The amount of fuel the pilot has.

Usage:

    p:setFuel( true ) -- Sets fuel to max
changeAI (p, newai)
Changes the pilot's AI. ( p, newai )

Parameters:

  • p Pilot Pilot to change AI of.
  • newai string Name of Ai to use.

Usage:

    p:changeAI( "empire" ) -- set the pilot to use the Empire AI
setTemp (p, temp[, slots=true])
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. ( p, temp, slots )

Parameters:

  • p Pilot Pilot to set health of.
  • temp number Value to set temperature to. Values below base temperature will be clamped.
  • slots boolean Whether slots should also be set to this temperature. (default 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.
setHealth (p, armour, shield[, stress=0])
Sets the health of a pilot.

This recovers the pilot's disabled state, although he may become disabled afterwards. ( p, armour, shield, stress )

Parameters:

  • p Pilot Pilot to set health of.
  • armour number Value to set armour to, should be double from 0-100 (in percent).
  • shield number Value to set shield to, should be double from 0-100 (in percent).
  • stress number Value to set stress (disable damage) to, should be double from 0-100 (in percent of current armour). (default 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
setEnergy (p, energy)
Sets the energy of a pilot. ( p, energy )

Parameters:

  • p Pilot Pilot to set energy of.
  • energy number 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.
setNoboard (p[, noboard=true])
Sets the ability to board the pilot.

No parameter is equivalent to true. ( p, noboard )

Parameters:

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

Usage:

    p:setNoboard( true ) -- Pilot can not be boarded by anyone
setNodisable (p[, disable=true])
Sets the ability of the pilot to be disabled.

No parameter is equivalent to true. ( p, disable )

Parameters:

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

Usage:

    p:setNodisable( true ) -- Pilot can not be disabled anymore.
setSpeedLimit (p, speed)
Limits the speed of a pilot. ( p, speed )

Parameters:

  • p pilot Pilot to set speed of.
  • speed number Value to set speed to.

Usage:

  • p:setSpeedLimit( 100 ) -- Sets maximumspeed to 100px/s.
  • p:setSpeedLimit( 0 ) removes speed limit.
health (p)
Gets the pilot's health. ( p )

Parameters:

  • p Pilot Pilot to get health of.

Returns:

  1. number The armour in % [0:100].
  2. number The shield in % [0:100].
  3. number The stress in % [0:100].
  4. boolean Indicates if pilot is disabled.

Usage:

    armour, shield, stress, dis = p:health()
energy (p)
Gets the pilot's energy. ( p )

Parameters:

  • p Pilot Pilot to get energy of.

Returns:

    number The energy of the pilot in % [0:100].

Usage:

    energy = p:energy()
lockon (p)
Gets the lockons on the pilot. ( p )

Parameters:

  • p Pilot Pilot to get lockons of.

Returns:

    number The number of lockons on the pilot.

Usage:

    lockon = p:lockon()
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
( p )

Parameters:

  • p Pilot Pilot to get stats of.

Returns:

    table A table containing the stats of p.

Usage:

    stats = p:stats() print(stats.armour)
cargoFree (p)
Gets the free cargo space the pilot has. ( p )

Parameters:

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

Returns:

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

Parameters:

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

Returns:

    number The amount of cargo the player has.
cargoAdd (p, type, quantity)
Tries to add cargo to the pilot's ship. ( p, type, quantity )

Parameters:

  • p Pilot The pilot to add cargo to.
  • type string Name of the cargo to add.
  • quantity number Quantity of cargo to add.

Returns:

    number The quantity of cargo added.

Usage:

    n = pilot.cargoAdd( player.pilot(), "Food", 20 )
cargoRm (p, type, quantity)
Tries to remove cargo from the pilot's ship. ( p, type, quantity )

Parameters:

  • p Pilot The pilot to remove cargo from.
  • type string Name of the cargo to remove.
  • quantity number Quantity of the cargo to remove.

Returns:

    number The number of cargo removed.

Usage:

    n = pilot.cargoRm( player.pilot(), "Food", 20 )
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.
( p )

Parameters:

  • p Pilot Pilot to list cargo of.

Returns:

    table An ordered list with the names of the cargo the pilot has.

Usage:

    for _,v in ipairs(pilot.cargoList(player.pilot())) do print( string.format("%s: %d", v.name, v.q ) ) end
colour (p)
Gets the pilot's colour based on hostility or friendliness to the player. ( p )

Parameters:

  • p Pilot Pilot to get the colour of.

Returns:

    Colour The pilot's colour.

Usage:

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

Parameters:

  • p Pilot Pilot to get the hostility of.

Returns:

    boolean The pilot's hostility status.

Usage:

    p:hostile()
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.
  • combat: pilot is engaged in combat.
( p )

Parameters:

  • p Pilot Pilot to get flags of.

Returns:

    table Table with flag names an index, boolean as value.
ship (p)
Gets the pilot's ship. ( p )

Parameters:

  • p Pilot Pilot to get ship of.

Returns:

    Ship The ship of the pilot.

Usage:

    s = p:ship()
idle (p)
Checks to see if the pilot is idle. ( p )

Parameters:

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

Returns:

    boolean true if pilot is idle, false otherwise

Usage:

    idle = p:idle() -- Returns true if the pilot is idle
control (p[, enable=1])
Sets manual control of the pilot. ( p, enable )

Parameters:

  • p Pilot Pilot to change manual control settings.
  • enable boolean If true or nil enables pilot manual control, otherwise enables automatic AI. (default 1)

See also:

Usage:

  • p:control() -- Same as p:control(true), enables manual control of the pilot
  • p:control(false) -- Restarts AI control of the pilot
memory (p)
Gets a pilots memory table.

The resulting table is indexable and mutable. ( p )

Parameters:

  • p Pilot Pilot to read memory of.

Usage:

  • aggr = p:memory().aggressive
  • p:memory().aggressive = false
taskClear (p)
Clears all the tasks of the pilot. ( p )

Parameters:

  • p Pilot Pilot to clear tasks of.

Usage:

    p:taskClear()
goto (p, v[, brake=1[, compensate=1]])
Makes the pilot goto a position.

Pilot must be under manual control for this to work. ( p, v, brake, compensate )

Parameters:

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

See also:

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
face (p, target[, towards=false])
Makes the pilot face a target. ( p, target, towards )

Parameters:

  • p Pilot Pilot to add task to.
  • target Vec2 or Pilot Target to face.
  • towards boolean Makes the task end when the target is faced (otherwise it's an enduring state). (default false)

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
brake (p)
Makes the pilot brake.

Pilot must be under manual control for this to work. ( p )

Parameters:

  • p Pilot Pilot to tell to brake.

See also:

follow (p, pt[, accurate=false])
Makes the pilot follow another pilot.

Pilot must be under manual control for this to work. ( p, pt, accurate )

Parameters:

  • p Pilot Pilot to tell to follow another pilot.
  • pt Pilot Target pilot to follow.
  • accurate boolean If true, use a PD controller which parameters can be defined using the pilot's memory. (default false)

See also:

attack (p[, pt])
Makes the pilot attack another pilot.

Pilot must be under manual control for this to work. ( p, pt )

Parameters:

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

See also:

Usage:

  • p:attack( another_pilot ) -- Attack another pilot
  • p:attack() -- Attack nearest pilot.
runaway (p, tp[, nojump=false])
Makes the pilot runaway from another pilot.

By default the pilot tries to jump when running away. ( p, tp, nojump )

Parameters:

  • p Pilot Pilot to tell to runaway from another pilot.
  • tp Pilot Target pilot to runaway from.
  • nojump boolean Whether or not the pilot should try to jump when running away. (default false)

See also:

Usage:

  • p:runaway( p_enemy ) -- Run away from p_enemy
  • p:runaway( p_enemy, true ) -- Run away from p_enemy but do not jump
hyperspace (p[, sys[, shoot]])
Tells the pilot to hyperspace.

Pilot must be under manual control for this to work. ( p, sys, shoot )

Parameters:

  • p Pilot Pilot to tell to hyperspace.
  • sys System Optional System to jump to, uses random if nil. (optional)
  • shoot boolean Whether or not to shoot at targets while running away with turrets. (optional)

See also:

land (p[, planet])
Tells the pilot to land Pilot must be under manual control for this to work. ( p, planet )

Parameters:

  • p Pilot Pilot to tell to land.
  • planet Planet Planet to land on, uses random if nil. (optional)

See also:

hailPlayer (p[, enable=true])
Marks the pilot as hailing the player.

Automatically deactivated when pilot is hailed. ( p, enable )

Parameters:

  • p Pilot Pilot to hail the player.
  • enable boolean If true hails the pilot, if false disables the hailing. (default true)

Usage:

    p:hailPlayer() -- Player will be informed he's being hailed and pilot will have an icon
msg (p, receiver, type[, data])
Sends a message to another pilot. ( p, receiver, type, data )

Parameters:

  • p Pilot Pilot to send message.
  • receiver Pilot or {Pilot,...} Pilot(s) to receive message.
  • type string Type of message.
  • data Data to send with message. (optional)
leader (p)
Gets a pilots leader. ( p )

Parameters:

  • p Pilot Pilot to get the leader of.

Returns:

    Pilot or nil The leader or nil.
setLeader (p, leader)
Set a pilots leader.

If leader has a leader itself, the leader will instead be set to that pilot's leader. ( p )

Parameters:

  • p Pilot Pilot to set the leader of.
  • leader Pilot or nil Pilot to set as leader.
followers (p)
Get all of a pilots followers. ( p )

Parameters:

  • p Pilot Pilot to get the followers of.

Returns:

    {Pilot,...} Table of followers.
hookClear (p)
Clears the pilot's hooks.

Clears all the hooks set on the pilot. ( p )

Parameters:

  • p Pilot Pilot to clear hooks.

Usage:

    p:hookClear()
generated by LDoc 1.4.3 Last updated 2020-06-26 02:01:09