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()
 rating = player.getRating()
 

Functions

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


Functions

player.addOutfit (name, q)
Adds an outfit to the player's outfit list.

Parameters

  • name: Name of the outfit to give.
  • q: Optional parameter that sets the 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
player.addShip (ship, name, loc, noname)
Gives the player a new ship.

Parameters

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

Usage:

player.addShip( "Pirate Kestrel", "Seiryuu" ) -- Gives the player a Pirate Kestrel named Seiryuu if player cancels the naming.
player.allowLand (b, 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.

Parameters

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

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."
player.allowSave (b)
Sets player save ability.

Parameters

  • b: true if the player is allowed to save, false otherwise. Defaults to true.

Usage:

player.allowSave( b )
player.autonav ()
Checks to see if the player has autonav enabled.

Usage:

autonav = player.autonav()

Return value:

true if the player has autonav enabled.
player.autonavDest ()
Gets the player's long term autonav destination.

Usage:

sys, jumps = player.autonavDest()

Return value:

The destination system (or nil if none selected) and the number of jumps left.
player.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

Parameters

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

Usage:

player.cinematics( true, { gui = true } ) -- Enables cinematics without hiding gui.
player.commClose ()
Forces the player to close comm if they are chatting.
player.credits (decimal)
Gets how many credits the player has on him.

Parameters

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

Usage

  • monies = player.credits()
  • monies, readable = player.credits( 2 )

Return value:

The amount of credits the player has on him in both numerical and human-readable form.
player.evtActive (name)
Checks to see if the player has an event active.

Parameters

  • name: Name of the mission to check.

Usage:

if player.evtActive( "Shipwreck" ) then -- The shipwreck event is active

Return value:

true if the mission is active, false if it isn't.
player.evtDone (name)
Checks to see if player has done an event. This only works with events that have the unique flag.

Parameters

  • name: Name of the event to check.

Usage:

if player.evtDone( "Shipwreck" ) then -- Player finished event

Return value:

true if event was finished, false if it wasn't.
player.fuel ()
Gets the amount of fuel a player has.

Usage:

fuel, consumption = player.fuel()

Return value:

The player's fuel and the amount needed per jump.
player.getRating ()
Gets the player's combat rating.

Return value:

Returns the combat rating (in raw number) and the actual standing in human readable form.
player.jumps ()
Gets a player's jump range based on their remaining fuel.

Usage:

jumps = player.jumps()

Return value:

The player's maximum number of jumps.
player.landWindow (winname)
Sets the active land window. Valid windows are:
- main
- bar
- missions
- outfits
- shipyard
- equipment
- commodity

Parameters

  • winname: Name of the window.

Usage:

player.landWindow( "outfits" )

Return value:

True on success.
player.misnActive (name)
Checks to see if the player has a mission active.

Parameters

  • name: Name of the mission to check.

Usage:

if player.misnActive( "The Space Family" ) then -- Player is doing space family mission

Return value:

true if the mission is active, false if it isn't.
player.misnDone (name)
Checks to see if player has done a mission. This only works with missions that have the unique flag.

Parameters

  • name: Name of the mission to check.

Usage:

if player.misnDone( "The Space Family" ) then -- Player finished mission

Return value:

true if mission was finished, false if it wasn't.
player.msg (message)
Sends the player an ingame message.

Parameters

  • message: Message to send the player.
player.msgClear ()
Clears the player's message buffer.
player.name ()
Gets the player's name.

Return value:

The name of the player.
player.numOutfit (name)
Gets the number of outfits the player owns in their list (excludes equipped on ships).

Parameters

  • name: Name of the outfit to give.

Usage:

q = player.numOutfit( "Laser Cannon" ) -- Number of 'Laser Cannons' the player owns (unequipped)

Return value:

The quantity the player owns.
player.omsgAdd (msg, duration, fontsize)
Adds an overlay message.

Parameters

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

Usage:

player.omsgAdd( "some_message", 5 )

Return value:

ID of the created overlay message.
player.omsgChange (id, msg, duration)
Changes an overlay message.

Parameters

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

Usage:

player.omsgChange( omsg_id, "new message", 3 )

Return value:

true if all went well, false otherwise.
player.omsgRm (id)
Removes an overlay message.

Parameters

  • id: ID of the overlay message to remove.

Usage:

player.omsgRm( msg_id )
player.outfits ()
Gets all the outfits the player owns. If you want the quantity, call player.numOutfit() on the individual outfit.

Usage:

player.outfits() -- A table of all the player's outfits.
player.pay (amount)
Pays the player an amount of money.

Parameters

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

Usage:

player.pay( 500 ) -- Gives player 500 credits
player.pilot ()
Gets the player's associated pilot.

Return value:

The player's pilot.
player.pos ()
Gets the player's position.

Usage:

v = player.pos()

Return value:

The position of the player (Vec2).
player.refuel (fuel)
Refuels the player.

Parameters

  • fuel:

Usage

  • player.refuel() -- Refuel fully
  • player.refuel( 200 ) -- Refuels partially
player.rmOutfit (name, q)
Removes an outfit from the player's outfit list. "all" will remove all outfits.

Parameters

  • name: Name of the outfit to give.
  • q: Optional parameter that sets the quantity to give (default 1).

Usage:

player.rmOutfit( "Plasma Blaster", 2 ) -- Removes two plasma blasters from the player
player.ship ()
Gets the player's ship's name.

Return value:

The name of the ship the player is currently in.
player.shipOutfits (name)
Gets the outfits for one of the player's ships.

Parameters

  • name:

Usage:

outfits = player.shipOutfits("Llama") -- Gets the Llama's outfits
player.ships ()
Gets the names of the player's ships.

Usage:

names = player.ships() -- The player's ship names.
player.swapShip (ship, name, loc, noname, remove)
Swaps the player's current ship with a new ship given to him.

Parameters

  • ship: Name of the ship to add.
  • name: Name to give the ship if player refuses to name it (defaults to shipname if omitted).
  • loc: Location to add to, if nil or omitted it adds it to local planet (must be landed).
  • noname: If true does not let the player name the ship (defaults to false).
  • remove: If true removes the player's current ship (so it replaces and doesn't swap).
player.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.
player.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.

Parameters

  • dest: 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.
player.unboard ()
Unboards the player from its boarded target. Use from inside a board hook.

Usage:

player.unboard()

Valid XHTML 1.0!