Naev

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

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


Functions

cur ()
Gets the current planet - MUST BE LANDED. ()

Returns:

  1. Planet The planet the player is landed on.
  2. System The system it is in.

Usage:

    p,s = planet.cur() -- Gets current planet (assuming landed)
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 raw (untranslated) name.
- table : Gets random planet belonging to any of the factions in the table.
( param )

Parameters:

  • param boolean, Faction, string or table See description.

Returns:

  1. Planet The matching planet.
  2. System The system it is in.

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
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. ( param )

Parameters:

  • param boolean, Faction, string or table See planet.get() description.

Returns:

  1. Planet The matching planet, if it is landable.
  2. System The system it is in.
getAll ()
Gets all the planets. ()

Returns:

    {Planet,...} An ordered list of all the planets.
system (p)
Gets the system corresponding to a planet. ( p )

Parameters:

  • p Planet Planet to get system of.

Returns:

    System or nil The system to which the planet belongs or nil if it has none.
__eq (p, comp)
You can use the '==' operator within Lua to compare planets with this. ( p, comp )

Parameters:

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

Returns:

    boolean true if both planets are the same.

Usage:

  • if p.__eq( planet.get( "Anecu" ) ) then -- Do something
  • if p == planet.get( "Anecu" ) then -- Do something
name (p)
Gets the planet's translated name.

This translated name should be used for display purposes (e.g. messages). It cannot be used as an identifier for the planet; for that, use planet.nameRaw() instead. ( p )

Parameters:

  • p Planet Planet to get the translated name of.

Returns:

    string The translated name of the planet.

Usage:

    name = p:name() -- Equivalent to `_(p:nameRaw())`
nameRaw (p)
Gets the planet's raw (untranslated) name.

This untranslated name should be used for identification purposes (e.g. can be passed to planet.get()). It should not be used directly for display purposes without manually translating it with _(). ( p )

Parameters:

  • p Planet Planet to get the raw name of.

Returns:

    string The raw name of the planet.

Usage:

    name = p:nameRaw()
radius (p)
Gets the planet's radius. ( p )

Parameters:

  • p Planet Planet to get the radius of.

Returns:

    number The planet's graphics radius.

Usage:

    radius = p:radius()
faction (p)
Gets the planet's faction. ( p )

Parameters:

  • p Planet Planet to get the faction of.

Returns:

    Faction The planet's faction, or nil if it has no faction.

Usage:

    f = p:faction()
colour (p)
Gets a planet's colour based on its friendliness or hostility to the player. ( p )

Parameters:

  • p Pilot Planet to get the colour of.

Returns:

    Colour The planet's colour.

Usage:

    col = p:colour()
class (p)
Gets the planet's class.

Usually classes are characters for planets and numbers for stations. ( p )

Parameters:

  • p Planet Planet to get the class of.

Returns:

    string The class of the planet in a one char identifier.

Usage:

    c = p:class()
services (p)
Checks for planet services.

Possible services are:
- "land"
- "inhabited"
- "refuel"
- "bar"
- "missions"
- "commodity"
- "outfits"
- "shipyard"
- "blackmarket"
( p )

Parameters:

  • p Planet Planet to get the services of.

Returns:

    table Table containing all the services.

Usage:

  • if p:services()["refuel"] then -- Planet has refuel service.
  • if p:services()["shipyard"] then -- Planet has shipyard service.
canLand (p)
Gets whether or not the player can land on the planet (or bribe it). ( p )

Parameters:

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

Returns:

  1. boolean The land status of the planet.
  2. boolean The bribability status of the planet.

Usage:

    can_land, can_bribe = p:canLand()
landOverride (p[, b=false])
Lets player land on a planet no matter what. The override lasts until the player jumps or lands. ( p, b )

Parameters:

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

Usage:

    p:landOverride( true ) -- Planet can land on p now.
getLandOverride (p)
Gets the land override status for a planet. ( p )

Parameters:

  • p Planet Planet to check.

Returns:

    b Whether or not the player is always allowed to land.

Usage:

    if p:getLandOverride() then -- Player can definitely land.
pos (p)
Gets the position of the planet in the system. ( p )

Parameters:

  • p Planet Planet to get the position of.

Returns:

    Vec2 The position of the planet in the system.

Usage:

    v = p:pos()
gfxSpace (p)
Gets the texture of the planet in space. ( p )

Parameters:

  • p Planet Planet to get texture of.

Returns:

    Tex The space texture of the planet.

Usage:

    gfx = p:gfxSpace()
gfxExterior (p)
Gets the texture of the planet in exterior. ( p )

Parameters:

  • p Planet Planet Planet to get texture of.

Returns:

    Tex The exterior texture of the planet.

Usage:

    gfx = p:gfxExterior()
shipsSold (p)
Gets the ships sold at a planet. ( p )

Parameters:

  • p Planet Planet to get ships sold at.

Returns:

    {Ship,...} An ordered table containing all the ships sold (empty if none sold).
outfitsSold (p)
Gets the outfits sold at a planet. ( p )

Parameters:

  • p Planet Planet to get outfits sold at.

Returns:

    {Outfit,...} An ordered table containing all the outfits sold (empty if none sold).
commoditiesSold (p)
Gets the commodities sold at a planet. ( p )

Parameters:

  • p Pilot Planet to get commodities sold at.

Returns:

    {Commodity,...} An ordered table containing all the commodities sold (empty if none sold).
blackmarket (p)
Checks to see if a planet is a black market. ( p )

Parameters:

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

Returns:

    boolean true if the planet is a black market.

Usage:

    b = p:blackmarket()
known (p)
Checks to see if a planet is known by the player. ( p )

Parameters:

  • p Planet Planet to check if the player knows.

Returns:

    boolean true if the player knows the planet.

Usage:

    b = p:known()
setKnown (p[, b=false])
Sets a planets's known state. ( p, b )

Parameters:

  • p Planet Planet to set known.
  • b boolean Whether or not to set as known. (default false)

Usage:

    p:setKnown( false ) -- Makes planet unknown.
recordCommodityPriceAtTime (p, t)
Records commodity prices at a given time, adding to players stats. ( p, t )

Parameters:

  • p Planet Planet to record prices at
  • t ntime_t Time at which to record prices.

Usage:

    p:recordCommodityPriceAtTime( t )
generated by LDoc 1.4.6 Last updated 2020-11-29 21:27:05