Home

Module player

Lua bindings to interact with the player.

These bindings let you modify stuff about the player and find out special information. General usage would be calls like:

 pname = player.name()
 shipname = player.ship()
 

Functions

name () Gets the player's name.
ship () Gets the player's ship's name.
pay (amount) Pays the player an amount of money.
credits (decimal) Gets how many credits the player has on him.
msg (message) Sends the player an ingame message.
msgClear () Clears the player's message buffer.
omsgAdd (msg, duration[, fontsize]) Adds an overlay message.
omsgChange (id, msg, duration) Changes an overlay message.
omsgRm (id) Removes an overlay message.
allowSave ([b=true]) Sets player save ability.
pos () Gets the player's position.
pilot () Gets the player's associated pilot.
jumps () Gets a player's jump range based on their remaining fuel.
fuel () Gets the amount of fuel a player has.
refuel ([fuel]) Refuels the player.
autonav () Checks to see if the player has autonav enabled.
autonavDest () Gets the player's long term autonav destination.
cinematics (enable, options) Puts the game in cinematics mode or back to regular mode.
unboard () Unboards the player from its boarded target.
takeoff () Forces the player to take off if they are landed.
allowLand ([b=true[, msg]]) Allows or disallows the player to land.
landWindow (winname) Sets the active land window.
commClose () Forces the player to close comm if they are chatting.
ships () Gets the names of the player's ships.
shipOutfits (name) Gets the outfits for one of the player's ships.
outfits () Gets all the outfits the player owns.
numOutfit (name) Gets the number of outfits the player owns in their list (excludes equipped on ships).
addOutfit (name[, q=1]) Adds an outfit to the player's outfit list.
rmOutfit (name[, q]) Removes an outfit from the player's outfit list.
addShip (ship[, name[, loc[, noname=false]]]) Gives the player a new ship.
swapShip (ship[, name[, loc[, noname=false[, remove=false]]]]) Swaps the player's current ship with a new ship given to him.
misnActive (name) Checks to see if the player has a mission active.
misnDone (name) Checks to see if player has done a mission.
evtActive (name) Checks to see if the player has an event active.
evtDone (name) Checks to see if player has done an event.
teleport (dest) Teleports the player to a new planet or system (only if not landed).


Functions

name ()
Gets the player's name. ()

Returns:

    string The name of the player.
ship ()
Gets the player's ship's name. ()

Returns:

    string The name of the ship the player is currently in.
pay (amount)
Pays the player an amount of money. ( amount )

Parameters:

  • amount number Amount of money to pay the player in credits.

Usage:

    player.pay( 500 ) -- Gives player 500 credits
credits (decimal)
Gets how many credits the player has on him. ( decimal )

Parameters:

  • decimal number Optional argument that makes it return human readable form with so many decimals.

Returns:

  1. number The amount of credits in numerical form.
  2. string The amount of credits in human-readable form.

Usage:

  • monies = player.credits()
  • monies, readable = player.credits( 2 )
msg (message)
Sends the player an ingame message. ( message )

Parameters:

  • message string Message to send the player.
msgClear ()
Clears the player's message buffer. ()
omsgAdd (msg, duration[, fontsize])
Adds an overlay message. ( msg, duration, fontsize )

Parameters:

  • msg string Message to add.
  • duration number Duration to add message (if 0. is infinite).
  • fontsize number Size of the font to use. (optional)

Returns:

    number ID of the created overlay message.

Usage:

    player.omsgAdd( "some_message", 5 )
omsgChange (id, msg, duration)
Changes an overlay message. ( id, msg, duration )

Parameters:

  • id number ID of the overlay message to change.
  • msg string Message to change to.
  • duration number New duration to set (0. for infinity).

Returns:

    boolean true if all went well, false otherwise.

Usage:

    player.omsgChange( omsg_id, "new message", 3 )
omsgRm (id)
Removes an overlay message. ( id )

Parameters:

  • id number ID of the overlay message to remove.

Usage:

    player.omsgRm( msg_id )
allowSave ([b=true])
Sets player save ability. ( b )

Parameters:

  • b boolean true if the player is allowed to save, false otherwise. (default true)

Usage:

    player.allowSave( b )
pos ()
Gets the player's position. ()

Returns:

    Vec2 The position of the player.

Usage:

    v = player.pos()
pilot ()
Gets the player's associated pilot. ()

Returns:

    Pilot The player's pilot.
jumps ()
Gets a player's jump range based on their remaining fuel. ()

Returns:

    number The player's maximum number of jumps.

Usage:

    jumps = player.jumps()
fuel ()
Gets the amount of fuel a player has. ()

Returns:

  1. number The player's fuel and
  2. number The amount of fuel needed per jump.

Usage:

    fuel, consumption = player.fuel()
refuel ([fuel])
Refuels the player. ( fuel )

Parameters:

  • fuel number Amount of fuel to add, will set to max if nil. (optional)

Usage:

  • player.refuel() -- Refuel fully
  • player.refuel( 200 ) -- Refuels partially
autonav ()
Checks to see if the player has autonav enabled. ()

Returns:

    boolean true if the player has autonav enabled.

Usage:

    autonav = player.autonav()
autonavDest ()
Gets the player's long term autonav destination. ()

Returns:

  1. System or nil The destination system (or nil if none selected).
  2. number or nil The number of jumps left.

Usage:

    sys, jumps = player.autonavDest()
cinematics (enable, options)
Puts the game in cinematics mode or back to regular mode.

Possible options are:

  • abort : (string) autonav abort message
  • no2x : (boolean) whether to prevent the player from engaging double-speed, default false
  • gui : (boolean) enables the player's gui, default disabled
( enable, options )

Parameters:

  • enable boolean If true sets cinematics mode, if false disables. Defaults to disable.
  • options table Table of options.

Usage:

    player.cinematics( true, { gui = true } ) -- Enables cinematics without hiding gui.
unboard ()
Unboards the player from its boarded target.

Use from inside a board hook. ()

Usage:

    player.unboard()
takeoff ()
Forces the player to take off if they are landed.

Assume the pilot is still landed until the current running function returns If you want to create pilots on take off please hook the takeoff/land hooks. ()

allowLand ([b=true[, msg]])
Allows or disallows the player to land.

This will allow or disallow landing on a system level and is reset when the player enters another system. ( b, msg )

Parameters:

  • b boolean Whether or not to allow the player to land. (default true)
  • msg string Message displayed when player tries to land (only if disallowed to land). Can be omitted to use default. (optional)

Usage:

  • player.allowLand() -- Allows the player to land
  • player.allowLand( false ) -- Doesn't allow the player to land.
  • player.allowLand( false, "No landing." ) -- Doesn't allow the player to land with the message "No landing."
landWindow (winname)
Sets the active land window.

Valid windows are:
- main
- bar
- missions
- outfits
- shipyard
- equipment
- commodity
( winname )

Parameters:

  • winname string Name of the window.

Returns:

    boolean True on success.

Usage:

    player.landWindow( "outfits" )
commClose ()
Forces the player to close comm if they are chatting. ()
ships ()
Gets the names of the player's ships. ()

Returns:

    {String,...} Table of ship names.

Usage:

    names = player.ships() -- The player's ship names.
shipOutfits (name)
Gets the outfits for one of the player's ships. ( name )

Parameters:

  • name string Name of the ship to get the outfits of.

Returns:

    {Outfit,...} Table of outfits.

Usage:

    outfits = player.shipOutfits("Llama") -- Gets the Llama's outfits
outfits ()
Gets all the outfits the player owns.

If you want the quantity, call player.numOutfit() on the individual outfit. ()

Returns:

    {Outfit,...} Table of outfits.

Usage:

    player.outfits() -- A table of all the player's outfits.
numOutfit (name)
Gets the number of outfits the player owns in their list (excludes equipped on ships). ( name )

Parameters:

  • name string Name of the outfit to give.

Returns:

    number The quantity the player owns.

Usage:

    q = player.numOutfit( "Laser Cannon" ) -- Number of 'Laser Cannons' the player owns (unequipped)
addOutfit (name[, q=1])
Adds an outfit to the player's outfit list. ( name, q )

Parameters:

  • name string Name of the outfit to give.
  • q number Quantity to give. (default 1)

Usage:

  • player.addOutfit( "Laser Cannon" ) -- Gives the player a laser cannon
  • player.addOutfit( "Plasma Blaster", 2 ) -- Gives the player two plasma blasters
rmOutfit (name[, q])
Removes an outfit from the player's outfit list.

"all" will remove all outfits. ( name, q )

Parameters:

  • name string Name of the outfit to give.
  • q number Quantity to remove (default 1). (optional)

Usage:

    player.rmOutfit( "Plasma Blaster", 2 ) -- Removes two plasma blasters from the player
addShip (ship[, name[, loc[, noname=false]]])
Gives the player a new ship.

( ship, name, loc, noname )

Parameters:

  • ship string Name of the ship to add.
  • name string Name to give the ship if player refuses to name it (defaults to shipname if omitted). (optional)
  • loc Planet Location to add to, if nil or omitted it adds it to local planet (must be landed). (optional)
  • noname boolean If true does not let the player name the ship. (default false)

Usage:

    player.addShip( "Pirate Kestrel", "Seiryuu" ) -- Gives the player a Pirate Kestrel named Seiryuu if player cancels the naming.
swapShip (ship[, name[, loc[, noname=false[, remove=false]]]])
Swaps the player's current ship with a new ship given to him. ( ship, name, loc, noname, remove )

Parameters:

  • ship string Name of the ship to add.
  • name string Name to give the ship if player refuses to name it (defaults to shipname if omitted). (optional)
  • loc Planet Location to add to, if nil or omitted it adds it to local planet (must be landed). (optional)
  • noname boolean If true does not let the player name the ship. (default false)
  • remove boolean If true removes the player's current ship (so it replaces and doesn't swap). (default false)
misnActive (name)
Checks to see if the player has a mission active. ( name )

Parameters:

  • name string Name of the mission to check.

Returns:

    boolean true if the mission is active, false if it isn't.

Usage:

    if player.misnActive( "The Space Family" ) then -- Player is doing space family mission
misnDone (name)
Checks to see if player has done a mission.

This only works with missions that have the unique flag. ( name )

Parameters:

  • name string Name of the mission to check.

Returns:

    boolean true if mission was finished, false if it wasn't.

Usage:

    if player.misnDone( "The Space Family" ) then -- Player finished mission
evtActive (name)
Checks to see if the player has an event active. ( name )

Parameters:

  • name string Name of the mission to check.

Returns:

    boolean true if the mission is active, false if it isn't.

Usage:

    if player.evtActive( "Shipwreck" ) then -- The shipwreck event is active
evtDone (name)
Checks to see if player has done an event.

This only works with events that have the unique flag. ( name )

Parameters:

  • name string Name of the event to check.

Returns:

    boolean true if event was finished, false if it wasn't.

Usage:

    if player.evtDone( "Shipwreck" ) then -- Player finished event
teleport (dest)
Teleports the player to a new planet or system (only if not landed).

If the destination is a system, the coordinates of the player will not change. If the destination is a planet, the player will be placed over that planet. ( dest )

Parameters:

  • dest System, Planet or string System or name of a system or planet or name of a planet to teleport the player to.

Usage:

  • player.teleport( system.get("Arcanis") ) -- Teleports the player to Arcanis.
  • player.teleport( "Arcanis" ) -- Teleports the player to Arcanis.
  • player.teleport( "Dvaer Prime" ) -- Teleports the player to Dvaer, and relocates him to Dvaer Prime.
generated by LDoc 1.4.3 Last updated 2020-05-21 06:15:36