Module spob
This module allows you to handle the spobs from Lua.
Generally you do something like:
p,s = spob.get() -- Get current spob and system if p:services()["inhabited"] > 0 then -- spob is inhabitedv = p:pos() -- Get the position -- Do other stuffend
Functions
cur () | Gets the current spob - MUST BE LANDED. |
get (param) | Gets a spob. |
getS (param) | Gets a spob and its corresponding system. |
getLandable (param) | Gets a spob only if it's landable. |
getAll (all_spob) | Gets all the spobs. |
system (p) | Gets the system corresponding to a spob. |
__eq (p, comp) | You can use the '==' operator within Lua to compare spobs with this. |
name (p) | Gets the spob's translated name. |
nameRaw (p) | Gets the spob's raw (untranslated) name. |
population (p) | Gets the spob's population. |
radius (p) | Gets the spob's radius. |
faction (p) | Gets the spob's faction. |
reputation (spb) | Gets the local reputation of the faction at a spob. |
colour (spb) | Gets a spob's colour based on its friendliness or hostility to the player. |
colourChar (spb) | Gets a spob's colour based on its friendliness or hostility to the player. |
class (p) | Gets the spob's class. |
classLong (p) | Gets the spob's class in long human-readable format already translated. |
services (p) | Checks for spob services. |
services (p) | Checks for spob flags. |
canLand (p) | Gets whether or not the player can land on the spob (or bribe it). |
landAllow (p[, b=false[, msg=nil]]) | Allows the player land on a spob no matter what. |
landDeny (p[, b=false[, msg=nil]]) | Disallows a player from landing on a spob. |
getLandAllow (p) | Gets the land allow override status for a spob. |
getLandDeny (p) | Gets the land deny override status for a spob. |
pos (p) | Gets the position of the spob in the system. |
gfxSpace (p) | Gets the texture of the spob in space. |
gfxExterior (p) | Gets the texture of the spob in exterior. |
gfxExteriorPath (p) | Gets the path of the spob in exterior. |
gfxComm (p) | Gets the texture of the spob for the communication window. |
shipsSold (p) | Gets the ships sold at a spob. |
outfitsSold (p) | Gets the outfits sold at a spob. |
commoditiesSold (p) | Gets the commodities sold at a spob. |
blackmarket (p) | Checks to see if a spob is a black market. |
known (p) | Checks to see if a spob is known by the player. |
setKnown (p[, b=false]) | Sets a spobs's known state. |
hostile (spb) | Checks to see if a spob currently has the hostile flag set. |
setHostile (spb) | Sets the hostile flag of a spob. |
recordCommodityPriceAtTime (p, t) | Records commodity prices at a given time, adding to players stats. |
tags (p[, tag=nil]) | Gets the spob tags. |
Functions
- cur ()
-
Gets the current spob - MUST BE LANDED.
Returns:
- Spob The spob the player is landed on.
- System The system it is in.
Usage:
p,s = spob.cur() -- Gets current spob (assuming landed)
- get (param)
-
Gets a spob.
Possible values of param:
- bool : Gets a random spob. <br/> - faction : Gets random spob belonging to faction matching the number.
- string : Gets the spob by raw (untranslated) name. <br/> - table : Gets random spob belonging to any of the factions in the table. <br/>
Parameters:
Returns:
-
Spob
The matching spob.
Usage:
p = spob.get( "Anecu" ) -- Gets spob by name
p = spob.get( faction.get( "Empire" ) ) -- Gets random Empire spob
p = spob.get(true) -- Gets completely random spob
p = spob.get( { faction.get("Empire"), faction.get("Dvaered") } ) -- Random spob belonging to Empire or Dvaered
- getS (param)
-
Gets a spob and its corresponding system.
Possible values of param:
- bool : Gets a random spob. <br/> - faction : Gets random spob belonging to faction matching the number.
- string : Gets the spob by raw (untranslated) name. <br/> - table : Gets random spob belonging to any of the factions in the table. <br/>
Parameters:
Returns:
- Spob The matching spob.
- System The system it is in.
Usage:
p,s = spob.get( "Anecu" ) -- Gets spob by name
p,s = spob.get( faction.get( "Empire" ) ) -- Gets random Empire spob
p,s = spob.get(true) -- Gets completely random spob
p,s = spob.get( { faction.get("Empire"), faction.get("Dvaered") } ) -- Random spob belonging to Empire or Dvaered
- getLandable (param)
-
Gets a spob only if it's landable.
It works exactly the same as spob.get(), but it can only return landable spobs. So if the target is not landable it returns nil.
Parameters:
Returns:
- Spob The matching spob, if it is landable.
- System The system it is in.
- getAll (all_spob)
-
Gets all the spobs.
Parameters:
- all_spob boolean Whether or not to get all Spob, including those that may not be located in a system at the time.
Returns:
-
{Spob,...}
An ordered list of all the spobs.
- system (p)
-
Gets the system corresponding to a spob.
Parameters:
- p Spob Spob to get system of.
Returns:
-
System or nil
The system to which the spob belongs or nil if it
has none.
- __eq (p, comp)
-
You can use the '==' operator within Lua to compare spobs with this.
Parameters:
- p Spob Spob comparing.
- comp Spob spob to compare against.
Returns:
-
boolean
true if both spobs are the same.
Usage:
if p.__eq( spob.get( "Anecu" ) ) then -- Do something
if p == spob.get( "Anecu" ) then -- Do something
- name (p)
-
Gets the spob's translated name.
This translated name should be used for display purposes (e.g. messages). It cannot be used as an identifier for the spob; for that, use spob.nameRaw() instead.
Note that it can be overwritten by the spob's display name which makes it not equivalent to _(p:nameRaw()) in some cases.
Parameters:
- p Spob Spob to get the translated name of.
Returns:
-
string
The translated name of the spob.
Usage:
name = p:name()
- nameRaw (p)
-
Gets the spob's raw (untranslated) name.
This untranslated name should be used for identification purposes (e.g. can be passed to spob.get()). It should not be used directly for display purposes without manually translating it with _().
Parameters:
- p Spob Spob to get the raw name of.
Returns:
-
string
The raw name of the spob.
Usage:
name = p:nameRaw()
- population (p)
-
Gets the spob's population.
Parameters:
- p Spob Spob to get the population of.
Returns:
-
number
The spob's population.
- radius (p)
-
Gets the spob's radius.
Parameters:
- p Spob Spob to get the radius of.
Returns:
-
number
The spob's graphics radius.
Usage:
radius = p:radius()
- faction (p)
-
Gets the spob's faction.
Parameters:
- p Spob Spob to get the faction of.
Returns:
-
Faction
The spob's faction, or nil if it has no faction.
Usage:
f = p:faction()
- reputation (spb)
-
Gets the local reputation of the faction at a spob.
Parameters:
- spb Spob Spob to get the reputation of.
Returns:
-
number
The reputation of the player at the space object.
- colour (spb)
-
Gets a spob's colour based on its friendliness or hostility to the
player.
Parameters:
- spb Spob Spob to get the colour of.
Returns:
-
Colour
The spob's colour.
Usage:
col = p:colour()
- colourChar (spb)
-
Gets a spob's colour based on its friendliness or hostility to the
player.
Parameters:
- spb Spob Spob to get the colour of.
Returns:
-
string
The spob's colour character for use with special
printing sequences..
Usage:
col = p:colourChar()
- class (p)
-
Gets the spob's class.
Usually classes are characters for spobs and numbers for stations.
Parameters:
- p Spob Spob to get the class of.
Returns:
-
string
The class of the spob in a one char identifier.
Usage:
c = p:class()
- classLong (p)
-
Gets the spob's class in long human-readable format already
translated.
Parameters:
- p Spob Spob to get the class of.
Returns:
-
string
The class of the spob in descriptive form such as
"Pelagic".
Usage:
c = p:classLong()
- services (p)
-
Checks for spob services.
Possible services are:
- "land"
- "inhabited"
- "refuel"
- "bar"
- "missions"
- "commodity"
- "outfits"
- "shipyard"
- "blackmarket"
Parameters:
- p Spob Spob to get the services of.
Returns:
-
table
Table containing all the services.
Usage:
if p:services()["refuel"] then -- Spob has refuel service.
if p:services()["shipyard"] then -- Spob has shipyard service.
- services (p)
-
Checks for spob flags.
Possible services are:
- "nomissionspawn"
Parameters:
- p Spob Spob to get the services of.
Returns:
-
table
Table containing all the services.
Usage:
if p:flags()["nomissionspawn"] then -- Spob doesn't spawn missions
- canLand (p)
-
Gets whether or not the player can land on the spob (or bribe it).
Parameters:
- p Spob Spob to get land and bribe status of.
Returns:
-
boolean
The land status of the spob.
Usage:
can_land, can_bribe = p:canLand()
- landAllow (p[, b=false[, msg=nil]])
-
Allows the player land on a spob no matter what. The override lasts
until the player jumps or lands.
Parameters:
- p Spob Spob 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)
- msg string Message to give the player when allowing them to land. Setting a message will bypass any custom Lua, otherwise it'll default to using Lua and, in the case there is no Lua, a default message. (default nil)
Usage:
p:landAllow( true ) -- Player can land on spob p now.
- landDeny (p[, b=false[, msg=nil]])
-
Disallows a player from landing on a spob. The override lasts until
the player jumps or lands.
Parameters:
- p Spob Spob to forcibly disallow the player to land on.
- b boolean Whether or not the player should be disallowed to land, true disables, false disables override. (default false)
- msg string Message to give the player when disallowing them to land. Setting a message will bypass any custom Lua, otherwise it'll default to using Lua and, in the case there is no Lua, a default message. (default nil)
Usage:
p:landDeny( true ) -- Player can land on spob p now.
- getLandAllow (p)
-
Gets the land allow override status for a spob.
Parameters:
- p Spob Spob to check.
Returns:
-
b
Whether or not the player is always allowed to land.
Usage:
if p:getLandAllow() then -- Player can definitely land.
- getLandDeny (p)
-
Gets the land deny override status for a spob.
Parameters:
- p Spob Spob to check.
Returns:
-
b
Whether or not the player is always disallowed to land.
Usage:
if p:getLandDeny() then -- Player can definitely not land
- pos (p)
-
Gets the position of the spob in the system.
Parameters:
- p Spob Spob to get the position of.
Returns:
-
Vec2
The position of the spob in the system.
Usage:
v = p:pos()
- gfxSpace (p)
-
Gets the texture of the spob in space.
Parameters:
- p Spob Spob to get texture of.
Returns:
-
Tex
The space texture of the spob.
Usage:
gfx = p:gfxSpace()
- gfxExterior (p)
-
Gets the texture of the spob in exterior.
Parameters:
- p Spob Spob Spob to get texture of.
Returns:
-
Tex
The exterior texture of the spob.
Usage:
gfx = p:gfxExterior()
- gfxExteriorPath (p)
-
Gets the path of the spob in exterior.
Parameters:
- p Spob Spob Spob to get texture of.
Returns:
-
string
The path to the exterior texture.
- gfxComm (p)
-
Gets the texture of the spob for the communication window.
Parameters:
- p Spob Spob Spob to get texture of.
Returns:
-
Tex
The communication texture of the spob.
Usage:
gfx = p:gfxComm()
- shipsSold (p)
-
Gets the ships sold at a spob.
Parameters:
- p Spob Spob 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 spob.
Parameters:
- p Spob Spob 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 spob.
Parameters:
- p Pilot Spob 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 spob is a black market.
Parameters:
- p Spob Spob to check if it's a black market.
Returns:
-
boolean
true if the spob is a black market.
Usage:
b = p:blackmarket()
- known (p)
-
Checks to see if a spob is known by the player.
Parameters:
- p Spob Spob to check if the player knows.
Returns:
-
boolean
true if the player knows the spob.
Usage:
b = p:known()
- setKnown (p[, b=false])
-
Sets a spobs's known state.
Parameters:
- p Spob Spob to set known.
- b boolean Whether or not to set as known. (default false)
Usage:
p:setKnown( false ) -- Makes spob unknown.
- hostile (spb)
-
Checks to see if a spob currently has the hostile flag set.
Parameters:
- spb Spob Spob to check hostile flag status of.
Returns:
-
boolean
Whether or not the spob is hostile.
- setHostile (spb)
-
Sets the hostile flag of a spob.
Parameters:
- spb Spob Spob to set hostile flag.
Returns:
-
boolean
Whether or not to set the hostile status.
- recordCommodityPriceAtTime (p, t)
-
Records commodity prices at a given time, adding to players stats.
Parameters:
- p Spob Spob to record prices at
- t ntime_t Time at which to record prices.
Usage:
p:recordCommodityPriceAtTime( t )
- tags (p[, tag=nil])
-
Gets the spob tags.
Parameters:
- p Spob Spob to get tags of.
- tag string Tag to check if exists. (default nil)
Returns:
-
table or boolean
Table of tags where the name is the key and true
is the value or a boolean value if a string is passed as the second parameter
indicating whether or not the specified tag exists.
Usage:
if spob.cur():tags()["fancy"] then -- Has "fancy" tag