Naev

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( "Llama", "Miner" ) -- Create a Miner Llama
 p:setFriendly() -- Make it friendly
 

Functions

choosePoint (f[, i=false[, g=false]]) Returns a suitable jumpin spot for a given pilot.
add (shipname, faction, param[, pilotname[, parameters]]) Adds a ship with an AI and faction to the system (instead of a predefined fleet).
clone (p) Clones a pilot.
rm (p) Removes a pilot without explosions or anything.
clearSelect (fac) Removes all pilots belonging to a faction from the system.
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.
getAllies (pilot[, dist=infinity[, pos=pilot.pos[, Whether=false[, disabled=false[, fighters=false]]]]]) Gets friendly pilots to a pilot (or faction) within a certain distance.
getHostiles (pilot[, dist=infinity[, pos=pilot.pos[, Whether=false[, disabled=false[, fighters=false]]]]]) Gets hostile pilots to a pilot (or faction) within a certain distance.
getVisible (pilot[, disabled=false]) Gets visible pilots to a pilot within a certain distance.
__eq (p, comp) Checks to see if pilot and p are the same.
name (p) Gets the pilot's current (translated) 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.
setTarget (p, t) Sets the pilot target of the pilot.
targetAsteroid (p) Gets the asteroid target of the pilot.
setTargetAsteroid (p, a) Sets the pilot's asteroid target.
inrange (p, target) Checks to see if a target pilot is in range of a pilot.
inrangeAsteroid (p, a) Checks to see if an asteroid is in range of a pilot.
scandone () Checks to see if a pilot is done scanning its target.
withPlayer (p) Checks to see if pilot is with player.
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[, sort=false]) Gets the active outfits and their states of the pilot.
outfits (p[, What=nil[, skip_locked=false]]) Gets the outfits of a pilot.
outfitByID (p, id) Gets a pilot's outfit by ID.
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.
mass (p) Gets the mass 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.
setHide (p, state) Sets the pilot's hide status.
setInvisible (p, state) Sets the pilot's invisibility status.
setInvisible (p, state) Sets the pilot's norender 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.
setHilight (p[, state=true]) Makes pilot act as if bribed by the player.
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[, nopermanent=false]) Disables a pilot.
cooldown (p) Gets a pilot's cooldown state.
setCooldown (p[, state=true]) Starts or stops a pilot's cooldown mode.
cooldownCycle (p) Makes the pilot do an instant full cooldown cycle.
setNoJump (p[, state=true]) Enables or disables a pilot's hyperspace engine.
setNoLand (p[, state]) Enables or disables landing for a pilot.
setNoClear (p[, state]) Enables or disables making the the pilot exempt from pilot.clear().
outfitAdd (p, outfit[, q=1[, bypass_cpu=false[, bypass_slot=false]]]) Adds an outfit to a pilot.
outfitSlot (p, slotname) Checks to see outfit a pilot has in a slot.
outfitAddSlot (p, outfit, slotname[, bypass_cpu=false[, bypass_slot=false]]) Adds an outfit to a pilot by slot name.
outfitRm (p, outfit, q) Removes an outfit from a pilot.
outfitRmSlot (p, slotname) Removes an outfit from a pilot's named slot.
outfitAddIntrinsic (p, o) Adds an intrinsic outfit to the pilot.
outfitRmIntrinsic (p, o) Removes an intrinsic outfit from the pilot.
setFuel (p, f) Sets the fuel of a pilot.
intrinsicReset () Resets the intrinsic stats of a pilot.
intrinsicSet (p, name, value, replace) Allows setting intrinsic stats of a pilot.
intrinsicGet (p[, name=nil][, internal=false], Value) Allows getting an intrinsic stats of a pilot, or gets all of them if name is not specified.
effectClear (p) Clears the effect on a pilot.
effectAdd (p, name[, Duration=-1[, Scaling=1]]) Adds an effect to a pilot.
effectGet (p) Gets the effects on a pilot.
changeAI (p, newai) Changes the pilot's AI.
setTemp (p, temp[, noslots=false]) Sets the temperature of a pilot.
setHealth (p[, armour=current armour[, shield=current shield[, stress=0]]]) Sets the health of a pilot.
addHealth (p[, armour=0.[, shield=0.]]) Adds health to a pilot.
setEnergy (p, energy[, absolute=false]) Sets the energy of a pilot.
fillAmmo (p) Fills up the pilot's ammo.
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[, absolute=false]) Gets the pilot's health.
energy (p[, absolute=false]) Gets the pilot's energy.
lockon (p) Gets the lockons on the pilot.
stats (p) Gets stats of the pilot.
shipstat (p[, name=nil[, internal=false]]) Gets a shipstat from a Pilot by name, or a table containing all the ship stats if not specified.
detectedDistance (p) Gets the distance that a pilot can be currently detect at.
cargoFree (p) Gets the free cargo space the pilot has.
cargoHas (p, cargo) Checks to see how many tonnes of a specific type of cargo the pilot has.
cargoAdd (p, cargo, quantity) Tries to add cargo to the pilot's ship.
cargoRm (p, cargo, quantity) Tries to remove cargo from the pilot's ship.
cargoList (p) Lists the cargo the pilot has.
credits (p[, cred=0]) Handles the pilots credits
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[, name]) Gets the pilot's flags.
hasIllegal (p, f) Checks to see if the pilot has illegal stuff to a faction.
ship (p) Gets the pilot's ship.
idle (p) Checks to see if the pilot is idle.
control (p[, enable=true[, Whether=true if changing modes]]) Sets manual control of the pilot.
memory (p) Gets a pilots memory table.
ainame (p) Gets the name of the task the pilot is currently doing.
task (p) Gets the name and data of a pilot's current task.
taskname (p) Gets the name of the task the pilot is currently doing.
taskstack (p) Gets the name of all the pilot's current tasks (not subtasks).
taskdata (p) Gets the data of the task the pilot is currently doing.
taskClear (p) Clears all the tasks of the pilot.
pushtask (p, func, data) Pushes a new task to the pilot's AI.
poptask (p) Pops the current task from the pilot's AI.
refuel (p, target[, amount=100]) Tries to refuel a pilot.
moveto (p, v[, brake=1[, compensate=1]]) Makes the pilot move to 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.
board (p, pt) Makes the pilot board another pilot.
runaway (p, tp[, destination.=false]) Makes the pilot runaway from another pilot.
gather () Makes the pilot gather stuff.
hyperspace (p[, sys[, noshoot=false]]) Tells the pilot to hyperspace.
stealth (p) Tells the pilot to try to stealth.
tryStealth (p) Tries to make the pilot stealth.
land (p[, spob[, noshoot=false]]) 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.
collisionTest (p, t) Tests to see if two ships collide.
damage (p, dmg[, disable=0.[, penetration=0.[, type="normal"[, shooter=nil]]]]) Damages a pilot.
knockback (p, m, v[, p=p:pos()[, e=1.]]) Knocks back a pilot.
calcStats (p) Forces a recomputation of the pilots' stats.
showEmitters ([state=true]) Toggles the emitter marker.
shipvarPeek (p, varname[, shipname]) Peeks at a ship variable.
shipvarPush (p, varname, val[, shipname]) Pushes a ship variable.
shipvarPop (p, varname[, shipname]) Pops a ship variable.
render (p) Renders the pilot to a canvas
renderTo (p, The) Renders the pilot to a canvas


Functions

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

Parameters:

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

Returns:

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

Usage:

    point = pilot.choosePoint( f, i, g )
    
add (shipname, faction, param[, pilotname[, parameters]])
Adds a ship with an AI and faction to the system (instead of a predefined fleet).

Parameters:

  • shipname string Name of the ship to add.
  • faction Faction Faction to give the pilot.
  • param System or Spob 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.
  • pilotname string Name to give the pilot. Defaults to shipname. (optional)
  • parameters table 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. (optional)

Returns:

    Pilot The created pilot.

Usage:

  • p = pilot.add( "Empire Shark", nil, "Empire" ) -- Creates a standard Empire Shark.
    
  • p = pilot.add( "Pirate Hyena", "Pirate", _("Blackbeard") ) -- Just adds the pilot (will jump in or take off).
    
  • p = pilot.add( "Llama", "Trader", nil, _("Trader Llama"), {ai="dummy"} ) -- Overrides AI with dummy ai.
    
  • p = pilot.add( "Gawain", "Civilian", vec2.new( 1000, 200 ) ) -- Pilot won't jump in, will just appear.
    
  • p = pilot.add( "Empire Pacifier", "Empire", system.get("Goddard") ) -- Have the pilot jump in from the system.
    
  • 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): <br/>
     - nil: spawns pilot randomly entering from jump points with presence of their faction or taking off from non-hostile spobs <br/>
     - spob: pilot takes off from the spob <br/>
     - system: jumps pilot in from the system <br/>
     - vec2: pilot is created at the position (no jump/takeoff) <br/>
     - true: Acts like nil, but does not avoid jump points with no presence <br/>
    
clone (p)
Clones a pilot. It will share nearly all properties including outfits.

Parameters:

  • p Pilot Pilot to clone.

Returns:

    Pilot A new clone of the pilot.
rm (p)
Removes a pilot without explosions or anything.

Parameters:

  • p Pilot Pilot to remove.

Usage:

    p:rm() -- pilot will be destroyed
    
clearSelect (fac)
Removes all pilots belonging to a faction from the system.

Parameters:

  • fac Faction Faction name/object to selectively clear.

Usage:

    pilot.clearSelect("Empire")
    
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.

Note Clears all global pilot hooks too.

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.

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
    
  • pilot.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.

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
    
getAllies (pilot[, dist=infinity[, pos=pilot.pos[, Whether=false[, disabled=false[, fighters=false]]]]])
Gets friendly pilots to a pilot (or faction) within a certain distance.

Parameters:

  • pilot Pilot or faction Pilot or to get allies of.
  • dist number Distance to look for allies. (default infinity)
  • pos Vec2 Position to check from. (default pilot.pos)
  • Whether boolean or not to only check for pilots in range (only in the case of pilot, not faction) (default false)
  • disabled boolean Whether or not to count disabled pilots. (default false)
  • fighters boolean Whether or not to count deployed fighters. (default false)

Returns:

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

Usage:

  • p:getAllies( 5000 ) -- get allies within 5000
    
  • pilot.getAllies( faction.get("Pirate"), 5000, vec2.new(0,0) ) -- Got allies of "Pirate" faction 5000 units from origin
    
getHostiles (pilot[, dist=infinity[, pos=pilot.pos[, Whether=false[, disabled=false[, fighters=false]]]]])
Gets hostile pilots to a pilot (or faction) within a certain distance.

Parameters:

  • pilot Pilot or faction Pilot or to get hostiles of.
  • dist number Distance to look for hostiles. (default infinity)
  • pos Vec2 Position to check from. (default pilot.pos)
  • Whether boolean or not to only check for pilots in range (only in the case of pilot, not faction) (default false)
  • disabled boolean Whether or not to count disabled pilots. (default false)
  • fighters boolean Whether or not to count deployed fighters. (default false)

Returns:

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

Usage:

  • p:getHostiles( 5000 ) -- get hostiles within 5000
    
  • pilot.getHostiles( faction.get("Pirate"), 5000, vec2.new(0,0) ) -- Got hostiles of "Pirate" faction 5000 units from origin
    
getVisible (pilot[, disabled=false])
Gets visible pilots to a pilot within a certain distance.

Parameters:

  • pilot Pilot Pilot to get visible pilots of.
  • disabled boolean Whether or not to count disabled pilots. (default false)

Returns:

    {Pilot,...} A table containing the pilots.
__eq (p, comp)
Checks to see if pilot and p are the same.

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 (translated) name.

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.

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.

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.

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()
    
setTarget (p, t)
Sets the pilot target of the pilot.

Parameters:

  • p Pilot Pilot to get target of.
  • t Pilot or nil Pilot to set the target to or nil to set no target.
targetAsteroid (p)
Gets the asteroid target of the pilot.

Parameters:

  • p Pilot Pilot to get asteroid target of.

Returns:

    table or nil nil if no asteroid is selected, otherwise a table with information about the selected asteroid.

Usage:

    target = p:targetAsteroid()
    
setTargetAsteroid (p, a)
Sets the pilot's asteroid target.

Parameters:

  • p Pilot Pilot to set asteroid target of.
  • a Asteroid Asteroid to set pilot's target to.
inrange (p, target)
Checks to see if a target pilot is in range of a pilot.

Parameters:

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

Returns:

  1. boolean True if the pilot is visible at all.
  2. boolean True if the pilot is visible and well-defined (not fuzzy)

Usage:

    detected, scanned = p:inrange( target )
    
inrangeAsteroid (p, a)
Checks to see if an asteroid is in range of a pilot.

Parameters:

  • p Pilot Pilot checking to see if an asteroid is in range.
  • a Asteroid Asteroid to check to see if is in range.

Returns:

    boolean true if in range, false otherwise.
scandone ()
Checks to see if a pilot is done scanning its target.

Returns:

    boolean True if the pilot has finished scanning their target.
withPlayer (p)
Checks to see if pilot is with player.

Parameters:

  • p Pilot Pilot to check to see if is with player.

Returns:

    boolean true if pilot is with player.
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 Pilot to get nav info of.

Returns:

  1. Spob or nil The pilot's spob target.
  2. System or nil The pilot's hyperspace target.

Usage:

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

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: 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.
  • 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 i, w in ipairs(ws) do
    print( "Name: " .. w.name )
    print( "Cooldown: " .. tostring(cooldown) )
    print( "Level: " .. tostring(level) )
 end
 

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.

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[, sort=false])
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 i, o in ipairs(act_outfits) do
    print( "Name: " .. o.name )
    print( "State: " .. o.state )
 end
 

Parameters:

  • p Pilot Pilot to get active outfits of.
  • sort boolean Whether or not to sort the otufits. (default false)

Returns:

    table The table with each active outfit's information.

Usage:

    act_outfits = p:actives() -- Gets the table of active outfits
    
outfits (p[, What=nil[, skip_locked=false]])
Gets the outfits of a pilot.

Parameters:

  • p Pilot Pilot to get outfits of.
  • What string slot type to get outfits of. Can be either nil, "weapon", "utility", "structure", or "intrinsic". (default nil)
  • skip_locked boolean Whether or not locked outfits should be ignored. (default false)

Returns:

    table The outfits of the pilot in an ordered list.
outfitByID (p, id)
Gets a pilot's outfit by ID.

Parameters:

  • p Pilot Pilot to get outf of.
  • id number ID of the outfit to get.

Returns:

    Outfit or nil Outfit equipped in the slot or nil otherwise.
rename (p, name)
Changes the pilot's 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.

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.

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.

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.

Parameters:

  • p Pilot Pilot to get the direction of.

Returns:

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

Usage:

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

Parameters:

  • p Pilot Pilot to get temperature of.

Returns:

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

Usage:

    t = p:temp()
    
mass (p)
Gets the mass of a pilot.

Parameters:

  • p Pilot Pilot to get mass of.

Returns:

    number The pilot's current mass (in tonnes).

Usage:

    m = p:mass()
    
faction (p)
Gets the pilot's faction.

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

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.

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.

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.

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

Parameters:

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

Usage:

    p:setDir( math.pi/2 )
    
broadcast (p, msg[, ignore_int=false])
Makes the pilot broadcast a message.

Parameters:

  • p Pilot or string 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.
  • 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
    
  • pilot.broadcast( "Message Buoy", _("Important annauncement") ) -- Messages player ignoring interference
    
comm (p, target, msg[, ignore_int=false])
Sends a message to the target or player if no target is passed.

Parameters:

  • p Pilot or string 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.
  • 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
    
  • pilot.comm( _("Message Buoy"), _("Important information just for you!") ) -- Messages player ignoring interference
    
setFaction (p, faction)
Sets the pilot's 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.

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.

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.

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.

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
    
setHide (p, state)
Sets the pilot's hide status.

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

Parameters:

  • p Pilot Pilot to set hidden status of.
  • state boolean State to set hide.

Usage:

  • p:setHide() -- p will disappear
    
  • p:setHide(true) -- p will disappear
    
  • p:setHide(false) -- p will appear again
    
setInvisible (p, state)
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.

Parameters:

  • p Pilot Pilot to set invisibility status of.
  • state boolean State to set invisibility.
setInvisible (p, state)
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".

Parameters:

  • p Pilot Pilot to set norender status of.
  • state boolean State to set norender.
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.

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.

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.

Parameters:

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

Usage:

    p:setHilight( true )
    
setHilight (p[, state=true])
Makes pilot act as if bribed by the player.

Parameters:

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

Usage:

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

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.

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[, nopermanent=false])
Disables a pilot.

Parameters:

  • p Pilot Pilot to disable.
  • nopermanent boolean Whether or not the disable should be not permanent. (default false)

Usage:

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

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.

Parameters:

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

Usage:

    p:setCooldown( true )
    
cooldownCycle (p)
Makes the pilot do an instant full cooldown cycle.

Parameters:

  • p Pilot Pilot to perform cycle.
setNoJump (p[, state=true])
Enables or disables a pilot's hyperspace engine.

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.

Parameters:

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

Usage:

    p:setNoLand( true )
    
setNoClear (p[, state])
Enables or disables making the the pilot exempt from pilot.clear().

Parameters:

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

Usage:

    p:setNoClear( true )
    
outfitAdd (p, outfit[, q=1[, bypass_cpu=false[, bypass_slot=false]]])
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.

Parameters:

  • p Pilot Pilot to add outfit to.
  • outfit string or outfit Outfit or name of the outfit to add.
  • q number Quantity of the outfit to add. (default 1)
  • bypass_cpu boolean Whether to skip CPU checks when adding an outfit. (default false)
  • bypass_slot boolean Whether or not to skip slot size checks before adding an outfit. Not that this implies skipping the CPU checks. (default false)

Returns:

    number The number of outfits added.

Usage:

    added = p:outfitAdd( "Laser Cannon", 5 ) -- Adds 5 laser cannons to p
    
outfitSlot (p, slotname)
Checks to see outfit a pilot has in a slot.

Parameters:

  • p Pilot Pilot to check outfit slot of.
  • slotname string Name of the slot to check.

Returns:

    Outfit or nil Outfit if applicable or nil otherwise.
outfitAddSlot (p, outfit, slotname[, bypass_cpu=false[, bypass_slot=false]])
Adds an outfit to a pilot by slot name.

Parameters:

  • p Pilot Pilot to add outfit to.
  • outfit string or outfit Outfit or name of the outfit to add.
  • slotname string Name of the slot to add to.
  • bypass_cpu boolean Whether to skip CPU checks when adding an outfit. (default false)
  • bypass_slot boolean or string 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). (default false)

Returns:

    boolean Whether or not the outfit was added.
outfitRm (p, outfit, q)
Removes an outfit from a pilot.

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

Parameters:

  • p Pilot Pilot to remove outfit from.
  • outfit string or outfit Outfit or name of the outfit to remove.
  • q number Quantity of the outfit to remove.

Returns:

    number The number of outfits removed.

Usage:

  • p:outfitRm( "all" ) -- Leaves the pilot naked (except for cores and locked outfits).
    
  • p:outfitRm( "cores" ) -- Strips the pilot of its cores, leaving it dead in space.
    
  • p:outfitRm( "Neutron Disruptor" ) -- Removes a neutron disruptor.
    
  • p:outfitRm( "Neutron Disruptor", 2 ) -- Removes two neutron disruptor.
    
outfitRmSlot (p, slotname)
Removes an outfit from a pilot's named slot.

Parameters:

  • p Pilot Pilot to remove outfit from.
  • slotname strin Name of the slot to remove the outfit from.

Returns:

    boolean true on success.
outfitAddIntrinsic (p, o)
Adds an intrinsic outfit to the pilot.

Parameters:

  • p Pilot Pilot to add intrinsic outfit to.
  • o Outfit Outfit to add as intrinsic outfit (must be modifier outfit).
outfitRmIntrinsic (p, o)
Removes an intrinsic outfit from the pilot.

Parameters:

  • p Pilot Pilot to remove intrinsic outfit from.
  • o Outfit Outfit to remove from intrinsic outfits.
setFuel (p, f)
Sets the fuel of a pilot.

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
    
intrinsicReset ()
Resets the intrinsic stats of a pilot.
intrinsicSet (p, name, value, replace)
Allows setting intrinsic stats of a pilot.

Parameters:

  • p Pilot Pilot to set stat of.
  • name string Name of the stat to set. It is the same as in the xml.
  • value number Value to set the stat to.
  • replace boolean Whether or not to add to the stat or replace it.
intrinsicGet (p[, name=nil][, internal=false], Value)
Allows getting an intrinsic stats of a pilot, or gets all of them if name is not specified.

Parameters:

  • p Pilot Pilot to get stat of.
  • name string Name of the stat to get. It is the same as in the xml. (default nil)
  • internal boolean Whether or not to use the internal representation. (default false)
  • Value of the stat or a table containing all the stats if name is not specified.
effectClear (p)
Clears the effect on a pilot.

Parameters:

  • p Pilot Pilot to clear effects of.
effectAdd (p, name[, Duration=-1[, Scaling=1]])
Adds an effect to a pilot.

Parameters:

  • p Pilot Pilot to add effect to.
  • name string Name of the effect to add.
  • Duration duration of the effect or set to negative to be default. (default -1)
  • Scaling scale factor. (default 1)

Returns:

    boolean Whether or not the effect was successfully added.
effectGet (p)
Gets the effects on a pilot.

Parameters:

  • p Pilot Pilot to get effects of.

Returns:

    table Table of effects which are treated as tables with "name" and "timer" elements.
changeAI (p, newai)
Changes the pilot's AI.

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[, noslots=false])
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 Pilot to set health of.
  • temp number Value to set temperature to. Values below base temperature will be clamped.
  • noslots boolean Whether slots should also be set to this temperature. (default false)

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=current armour[, shield=current shield[, stress=0]]])
Sets the health of a pilot.

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

Parameters:

  • p Pilot Pilot to set health of.
  • armour number Value to set armour to, should be double from 0-100 (in percent). (default current armour)
  • shield number Value to set shield to, should be double from 0-100 (in percent). (default current shield)
  • 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
    
addHealth (p[, armour=0.[, shield=0.]])
Adds health to a pilot.

Does not revive dead pilots, use setHealth for that.

Parameters:

  • p Pilot Pilot to add health to.
  • armour number Armour to add. (default 0.)
  • shield number Shield to add. (default 0.)
setEnergy (p, energy[, absolute=false])
Sets the energy of a pilot.

Parameters:

  • p Pilot Pilot to set energy of.
  • energy number Value to set energy to, should be double from 0-100 (in percent).
  • absolute boolean Whether or not it is being set in relative value or absolute. (default false)

Usage:

  • p:setEnergy( 100 ) -- Sets pilot to full energy.
    
  • p:setEnergy(  70 ) -- Sets pilot to 70% energy.
    
fillAmmo (p)
Fills up the pilot's ammo.

Parameters:

  • p Pilot Pilot to fill ammo.
setNoboard (p[, noboard=true])
Sets the ability to board the pilot.

No parameter is equivalent to true.

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.

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.

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

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[, absolute=false])
Gets the pilot's health.

Parameters:

  • p Pilot Pilot to get health of.
  • absolute boolean Whether or not it shouldn't be relative and be absolute instead. (default false)

Returns:

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

Usage:

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

Parameters:

  • p Pilot Pilot to get energy of.
  • absolute boolean Whether or not to return the absolute numeric value instead of the relative value. (default false)

Returns:

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

Usage:

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

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

Parameters:

  • p Pilot Pilot to get stats of.

Returns:

    table A table containing the stats of p.

Usage:

    stats = p:stats() print(stats.armour)
    
shipstat (p[, name=nil[, internal=false]])
Gets a shipstat from a Pilot by name, or a table containing all the ship stats if not specified.

Parameters:

  • p Pilot Pilot to get ship stat of.
  • name string Name of the ship stat to get. (default nil)
  • internal boolean Whether or not to use the internal representation. (default false)

Returns:

    Value of the ship stat or a table containing all the ship stats if name is not specified.
detectedDistance (p)
Gets the distance that a pilot can be currently detect at.

Parameters:

  • p Pilot Pilot to get the distance they can be detected at.
cargoFree (p)
Gets the free cargo space the pilot has.

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, cargo)
Checks to see how many tonnes of a specific type of cargo the pilot has.

Parameters:

  • p Pilot The pilot to get the cargo count of.
  • cargo Commodity or string Type of cargo to check, either as a Commodity object or as the raw (untranslated) name of a commodity.

Returns:

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

Parameters:

  • p Pilot The pilot to add cargo to.
  • cargo Commodity or string Type of cargo to add, either as a Commodity object or as the raw (untranslated) name of a commodity.
  • quantity number Quantity of cargo to add.

Returns:

    number The quantity of cargo added.

Usage:

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

Parameters:

  • p Pilot The pilot to remove cargo from.
  • cargo Commodity or string 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.
  • quantity number Quantity of the cargo to remove.

Returns:

    number The number of cargo removed.

Usage:

  • n = pilot.cargoRm(player.pilot(), "Food", 20)
    
  • n = pilot.cargoRm(player.pilot(), "all") -- Removes all cargo from the player
    
cargoList (p)
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()).
  • q: quantity of the cargo.
  • m: true if cargo is for a mission.

Parameters:

  • p Pilot Pilot to list cargo of.

Returns:

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

Usage:

    for i, v in ipairs(pilot.cargoList(player.pilot())) do print( string.format("%s: %d", v.name, v.q ) ) end
    
credits (p[, cred=0])
Handles the pilots credits

Parameters:

  • p Pilot Pilot to manipulate credits of.
  • cred number Credits to give to the pilot. (default 0)

Returns:

    number The credits the pilot has.
colour (p)
Gets the pilot's colour based on hostility or friendliness to the player.

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.

Parameters:

  • p Pilot Pilot to get the hostility of.

Returns:

    boolean The pilot's hostility status.

Usage:

    p:hostile()
    
flags (p[, name])
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.
  • 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.

Parameters:

  • p Pilot Pilot to get flags of.
  • name string If provided, return only the individual flag. (optional)

Returns:

    table Table with flag names an index, boolean as value.
hasIllegal (p, f)
Checks to see if the pilot has illegal stuff to a faction.

Parameters:

  • p Pilot Pilot to check.
  • f Faction Faction to see if it is illegal to.
ship (p)
Gets the pilot's ship.

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.

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=true[, Whether=true if changing modes]])
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.

Parameters:

  • p Pilot Pilot to change manual control settings.
  • enable boolean If true or nil enables pilot manual control, otherwise enables automatic AI. (default true)
  • Whether boolean or not to clear the tasks for the pilot. Defaults to true when changing from manual to normal mode or viceversa. (default true if changing modes)

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
    
  • p:control( true, true ) -- Enables manual control of the pilot and resets tasks.
    
memory (p)
Gets a pilots memory table.

The resulting table is indexable and mutable.

Parameters:

  • p Pilot Pilot to read memory of.

Usage:

  • aggr = p:memory().aggressive
    
  • p:memory().aggressive = false
    
ainame (p)
Gets the name of the task the pilot is currently doing.

Parameters:

  • p Pilot Pilot to get task name of.

Returns:

    string Name of the task.
task (p)
Gets the name and data of a pilot's current task.

Parameters:

  • p Pilot Pilot to get task data of.

Returns:

  1. string Name of the task.
  2. Data of the task.
taskname (p)
Gets the name of the task the pilot is currently doing.

Parameters:

  • p Pilot Pilot to get task name of.

Returns:

    string Name of the task.
taskstack (p)
Gets the name of all the pilot's current tasks (not subtasks).

Parameters:

  • p Pilot Pilot to get task stack of.
taskdata (p)
Gets the data of the task the pilot is currently doing.

Parameters:

  • p Pilot Pilot to get task data of.

Returns:

    Data of the task.
taskClear (p)
Clears all the tasks of the pilot.

Parameters:

  • p Pilot Pilot to clear tasks of.

Usage:

    p:taskClear()
    
pushtask (p, func, data)
Pushes a new task to the pilot's AI.

Equivalent to ai.pushtask()

Parameters:

  • p Pilot Pilot to push task to.
  • func string Name of the function to be run.
  • data any Data to be passed to the function.
poptask (p)
Pops the current task from the pilot's AI.

Equivalent to ai.poptask().

Parameters:

  • p Pilot Pilot to pop task from.
refuel (p, target[, amount=100])
Tries to refuel a pilot.

Parameters:

  • p Pilot Pilot to do the refueling.
  • target Pilot Target pilot to give fuel to.
  • amount number Amount to refuel. (default 100)
moveto (p, v[, brake=1[, compensate=1]])
Makes the pilot move to a position.

Pilot must be under manual control for this to work.

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:moveto( v ) -- Goes to v precisely and braking
    
  • p:moveto( v, true, true ) -- Same as p:moveto( v )
    
  • p:moveto( v, false ) -- Goes to v without braking compensating velocity
    
  • p:moveto( v, false, false ) -- Really rough approximation of going to v without braking
    
face (p, target[, towards=false])
Makes the pilot face a target.

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.

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.

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.

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.
    
board (p, pt)
Makes the pilot board another pilot.

Pilot must be under manual control for this to work.

Parameters:

  • p Pilot Pilot to tell to board another pilot.
  • pt Pilot Target pilot to board

See also:

Usage:

    p:board( another_pilot ) -- Attack another pilot
    
runaway (p, tp[, destination.=false])
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.

Parameters:

  • p Pilot Pilot to tell to runaway from another pilot.
  • tp Pilot Target pilot to runaway from.
  • destination. boolean, Jump or Spob (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
    
gather ()
Makes the pilot gather stuff.

See also:

Usage:

    p:gather( ) -- Try to gather stuff
    
hyperspace (p[, sys[, noshoot=false]])
Tells the pilot to hyperspace.

Pilot must be under manual control for this to work.

Parameters:

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

See also:

stealth (p)
Tells the pilot to try to stealth.

Pilot must be under manual control for this to work.

Parameters:

  • p Pilot Pilot to tell to try to stealth.

See also:

tryStealth (p)
Tries to make the pilot stealth.

Parameters:

  • p Pilot Pilot to try to make stealth.

Returns:

    boolean Whether or not the pilot was able to stealth.
land (p[, spob[, noshoot=false]])
Tells the pilot to land Pilot must be under manual control for this to work.

Parameters:

  • p Pilot Pilot to tell to land.
  • spob Spob Spob to land on, uses random if nil. (optional)
  • noshoot boolean Forbids to shoot at targets with turrets while running away. (default false)

See also:

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

Automatically deactivated when pilot is hailed.

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.

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

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.

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.

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.

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.

Parameters:

  • p Pilot Pilot to clear hooks.

Usage:

    p:hookClear()
    
collisionTest (p, t)
Tests to see if two ships collide.

Parameters:

  • p Pilot First pilot to check.
  • t Pilot Second pilot to check.

Returns:

    Vec2 or nil nil if no collision, or Vec2 with collision point if collided.
damage (p, dmg[, disable=0.[, penetration=0.[, type="normal"[, shooter=nil]]]])
Damages a pilot.

Parameters:

  • p Pilot Pilot being damaged.
  • dmg number Damage being done.
  • disable number Disable being done. (default 0.)
  • penetration number Penetration (in %). (default 0.)
  • type string Damage type being done. (default "normal")
  • shooter Pilot Pilot doing the damage. (default nil)

Returns:

    number Amount of damage done.
knockback (p, m, v[, p=p:pos()[, e=1.]])
Knocks back a pilot. It can either accept two pilots, or a pilot and an element represented by mass, velocity, and position.

Parameters:

  • p Vec2 Position of the object knocking back the pilot. (default p:pos())
  • m number Mass of object knocking back pilot.
  • v Vec2 Velocity of object knocking back pilot.
  • p Vec2 Position of the object knocking back the pilot. (default p:pos())
  • e number Coefficient of restitution. Use 1. for elastic collisions, and 0. for inelastic collisions. (default 1.)
calcStats (p)
Forces a recomputation of the pilots' stats.

Parameters:

  • p Pilot Pilot to recalculate stats of.
showEmitters ([state=true])
Toggles the emitter marker.

Parameters:

  • state boolean Whether to set or unset markers. (default true)

Usage:

  • pilot.showEmitters() -- Trail emitters are marked with crosses.
    
  • pilot.showEmitters(false) -- Remove the markers.
    
shipvarPeek (p, varname[, shipname])
Peeks at a ship variable.

Parameters:

  • p Pilot Pilot whose ship variable is being manipulated.
  • varname string Name of the variable to check value of.
  • shipname string Name of the ship to check variable of. Defaults to pilot's current ship. (optional)

Usage:

    local exp = p:shipvarPeek( "exp" ) -- Checks the value of the "exp" ship var on the player's current ship
    
shipvarPush (p, varname, val[, shipname])
Pushes a ship variable.

Parameters:

  • p Pilot Pilot whose ship variable is being manipulated.
  • varname string Name of the variable to set value of.
  • val Value to push.
  • shipname string Name of the ship to push variable to. Defaults to pilot's current ship. (optional)
shipvarPop (p, varname[, shipname])
Pops a ship variable.

Parameters:

  • p Pilot Pilot whose ship variable is being manipulated.
  • varname string Name of the variable to pop.
  • shipname string Name of the ship to pop variable from. Defaults to pilot's current ship. (optional)
render (p)
Renders the pilot to a canvas

Parameters:

  • p Pilot Pilot whose ship is being rendered.

Returns:

    Canvas The canvas with the pilot drawn on it.
renderTo (p, The)
Renders the pilot to a canvas

Parameters:

  • p Pilot Pilot whose ship is being rendered.
  • The Canvas canvas to draw to (uses bottom-left corner).

Returns:

  1. number Width drawn.
  2. number Height drawn.
generated by LDoc 1.4.6 Last updated 2022-05-26 02:36:04