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.
getS (param) Gets a planet and its corresponding system.
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.
classLong (p) Gets the planet's class in long human-readable format already translated.
services (p) Checks for planet services.
services (p) Checks for planet flags.
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.
restricted (p) Checks to see if a planet is restricted (has complicated land condition).
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.
tags (p) Gets the planet tags.


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.

Parameters:

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

Returns:

    Planet The matching planet.

Usage:

  • p = planet.get( "Anecu" ) -- Gets planet by name
    
  • p = planet.get( faction.get( "Empire" ) ) -- Gets random Empire planet
    
  • p = planet.get(true) -- Gets completely random planet
    
  • p = planet.get( { faction.get("Empire"), faction.get("Dvaered") } ) -- Random planet belonging to Empire or Dvaered
    
getS (param)
Gets a planet and its corresponding system.

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.

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.

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.

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.

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.

Note that it can be overwritten by the planet's display name which makes it not equivalent to _(p:nameRaw()) in some cases.

Parameters:

  • p Planet Planet to get the translated name of.

Returns:

    string The translated name of the planet.

Usage:

    name = p:name()
    
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 _().

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.

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.

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.

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.

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()
    
classLong (p)
Gets the planet's class in long human-readable format already translated.

Parameters:

  • p Planet Planet to get the class of.

Returns:

    string The class of the planet in descriptive form such as "Pelagic".

Usage:

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

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

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.
    
services (p)
Checks for planet flags.

Possible services are:
- "nomissionspawn"

Parameters:

  • p Planet Planet to get the services of.

Returns:

    table Table containing all the services.

Usage:

    if p:flags()["nomissionspawn"] then -- Planet doesn't spawn missions
    
canLand (p)
Gets whether or not the player can land on the planet (or bribe it).

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.

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.

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.

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.

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.

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.

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.

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.

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.

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()
    
restricted (p)
Checks to see if a planet is restricted (has complicated land condition).

Parameters:

  • p Planet Planet to check if it's restricted.

Returns:

    boolean true if the planet is restricted.

Usage:

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

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.

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.

Parameters:

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

Usage:

    p:recordCommodityPriceAtTime( t )
    
tags (p)
Gets the planet tags.

Parameters:

  • p Planet Planet to get tags of.

Returns:

    table Table of tags where the name is the key and true is the value.

Usage:

    if planet.cur():tags["fancy"] then -- Has "fancy" tag
    
generated by LDoc 1.4.6 Last updated 2021-12-26 19:10:22