Home

Module planet

This module allows you to handle the planets from Lua. Generally you do something like:
 p,s = planet.get() -- Get current planet and system
 if p:services()["inhabited"] > 0 then -- planet is inhabited
 v = p:pos() -- Get the position
 -- Do other stuff
 end
 

Functions

planet.__eq (p, comp) You can use the '=' operator within Lua to compare planets with this.
planet.blackmarket (p) Checks to see if a planet is a black market.
planet.canLand (p) Gets whether or not the player can land on the planet (or bribe it).
planet.class (p) Gets the planet's class.
planet.colour (p) Gets a planet's colour based on its friendliness or hostility to the player.
planet.commoditiesSold (p) Gets the commodities sold at a planet.
planet.cur () Gets the current planet - MUST BE LANDED.
planet.faction (p) Gets the planet's faction.
planet.get (param) Gets a planet.
planet.getAll () Gets all the planets.
planet.getLandOverride (p, b) Gets the land override status for a planet.
planet.getLandable (param) Gets a planet only if it's landable.
planet.gfxExterior (p) Gets the texture of the planet in exterior.
planet.gfxSpace (p) Gets the texture of the planet in space.
planet.known (p, s) Checks to see if a planet is known by the player.
planet.landOverride (p, b) Lets player land on a planet no matter what.
planet.name (p) Gets the planet's radius.
planet.name (p) Gets the planet's radius.
planet.outfitsSold (p) Gets the outfits sold at a planet.
planet.pos (p) Gets the position of the planet in the system.
planet.services (p) Checks for planet services.
planet.setKnown (p, b) Sets a planets's known state.
planet.shipsSold (p) Gets the ships sold at a planet.
planet.system (p) Gets the system corresponding to a planet.


Functions

planet.__eq (p, comp)
You can use the '=' operator within Lua to compare planets with this.

Parameters

  • p: Planet comparing.
  • comp: planet to compare against.

Usage

  • if p.__eq( planet.get( "Anecu" ) ) then -- Do something
  • if p == planet.get( "Anecu" ) then -- Do something

Return value:

true if both planets are the same.
planet.blackmarket (p)
Checks to see if a planet is a black market.

Parameters

  • p: Planet to check if it's a black market.

Usage:

b = p:blackmarket()

Return value:

true if the planet is a black market.
planet.canLand (p)
Gets whether or not the player can land on the planet (or bribe it).

Parameters

  • p: Planet to get land and bribe status of.

Usage:

can_land, can_bribe = p:canLand()

Return value:

The land and bribability status of the planet.
planet.class (p)
Gets the planet's class. Usually classes are characters for planets and numbers for stations.

Parameters

  • p: Planet to get the class of.

Usage:

c = p:class()

Return value:

The class of the planet in a one char identifier.
planet.colour (p)
Gets a planet's colour based on its friendliness or hostility to the player.

Parameters

  • p: Planet to get the colour of.

Usage:

col = p:colour()

Return value:

The planet's colour.
planet.commoditiesSold (p)
Gets the commodities sold at a planet.

Parameters

  • p: Planet to get commodities sold at.

Return value:

An ordered table containing all the commodities sold (empty if none sold).
planet.cur ()
Gets the current planet - MUST BE LANDED.

Usage:

p,s = planet.cur() -- Gets current planet (assuming landed)

Return value:

The planet and system in belongs to.
planet.faction (p)
Gets the planet's faction.

Parameters

  • p: Planet to get the faction of.

Usage:

f = p:faction()

Return value:

The planet's faction.
planet.get (param)
Gets a planet. Possible values of param:
- bool : Gets a random planet.
- faction : Gets random planet belonging to faction matching the number.
- string : Gets the planet by name.
- table : Gets random planet belonging to any of the factions in the table.

Parameters

  • param: See description.

Usage

  • p,s = planet.get( "Anecu" ) -- Gets planet by name
  • p,s = planet.get( faction.get( "Empire" ) ) -- Gets random Empire planet
  • p,s = planet.get(true) -- Gets completely random planet
  • p,s = planet.get( { faction.get("Empire"), faction.get("Dvaered") } ) -- Random planet belonging to Empire or Dvaered

Return value:

Returns the planet and the system it belongs to.
planet.getAll ()
Gets all the planets.

Return value:

An ordered list of all the planets.
planet.getLandOverride (p, b)
Gets the land override status for a planet.

Parameters

  • p: Planet to check.
  • b: Whether or not the player is always allowed to land.

Usage:

if p:getLandOverride() then -- Player can definitely land.
planet.getLandable (param)
Gets a planet only if it's landable. It works exactly the same as planet.get(), but it can only return landable planets. So if the target is not landable it returns nil.

Parameters

  • param: See planet.get() description.

Return value:

Returns the planet and sytem it belongs to or nil and nil if it is not landable.
planet.gfxExterior (p)
Gets the texture of the planet in exterior.

Parameters

  • p: Planet to get texture of.

Return value:

The exterior texture of the planet.
planet.gfxSpace (p)
Gets the texture of the planet in space.

Parameters

  • p: Planet to get texture of.

Return value:

The space texture of the planet.
planet.known (p, s)
Checks to see if a planet is known by the player.

Parameters

  • p:
  • s: Planet to check if the player knows.

Usage:

b = p:known()

Return value:

true if the player knows the planet.
planet.landOverride (p, b)
Lets player land on a planet no matter what. The override lasts until the player jumps or lands.

Parameters

  • p: Planet to forcibly allow the player to land on.
  • b: Whether or not the player should be allowed to land, true enables, false disables override.

Usage:

p:landOverride( true ) -- Planet can land on p now.
planet.name (p)
Gets the planet's radius.

Parameters

  • p: Planet to get the radius of.

Usage:

radius = p:radius()

Return value:

The planet's graphics radius.
planet.name (p)
Gets the planet's radius.

Parameters

  • p: Planet to get the radius of.

Usage:

radius = p:radius()

Return value:

The planet's graphics radius.
planet.outfitsSold (p)
Gets the outfits sold at a planet.

Parameters

  • p: Planet to get outfits sold at.

Return value:

An ordered table containing all the outfits sold (empty if none sold).
planet.pos (p)
Gets the position of the planet in the system.

Parameters

  • p: Planet to get the position of.

Usage:

v = p:pos()

Return value:

The position of the planet in the system as a vec2.
planet.services (p)
Checks for planet services. Possible services are:
- "land"
- "inhabited"
- "refuel"
- "bar"
- "missions"
- "commodity"
- "outfits"
- "shipyard"

Parameters

  • p: Planet to get the services of.

Usage

  • if p:services()["refuel"] then -- Planet has refuel service.
  • if p:services()["shipyard"] then -- Planet has shipyard service.

Return value:

Table containing all the services.
planet.setKnown (p, b)
Sets a planets's known state.

Parameters

  • p: Planet to set known.
  • b: Whether or not to set as known (defaults to false).

Usage:

p:setKnown( false ) -- Makes planet unknown.
planet.shipsSold (p)
Gets the ships sold at a planet.

Parameters

  • p: Planet to get ships sold at.

Return value:

An ordered table containing all the ships sold (empty if none sold).
planet.system (p)
Gets the system corresponding to a planet.

Parameters

  • p: Planet to get system of.

Return value:

The system to which the planet belongs or nil if it has none.

Valid XHTML 1.0!