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
__eq (p, comp) | You can use the '==' operator within Lua to compare spobs with this. |
blackmarket (p) | Checks to see if a spob is a black market. |
canLand (p) | Gets whether or not the player can land on the spob (or bribe it). |
class (p) | Gets the spob's class. |
classLong (p) | Gets the spob's class in long human-readable format already translated. |
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. |
commoditiesSold (p) | Gets the commodities sold at a spob. |
cur () | Gets the current spob - MUST BE LANDED. |
exists (name) | Tries to get a spob. |
faction (p) | Gets the spob's faction. |
flags (p) | Checks for spob flags. |
get (param) | Gets a spob. |
getAll (all_spob) | Gets all the spobs. |
getLandAllow (p) | Gets the land allow override status for a spob. |
getLandDeny (p) | Gets the land deny override status for a spob. |
getLandable (param) | Gets a spob only if it's landable. |
getS (param) | Gets a spob and its corresponding system. |
gfxComm (p) | Gets the texture of the spob for the communication window. |
gfxExterior (p) | Gets the texture of the spob in exterior. |
gfxExteriorPath (p) | Gets the path of the spob in exterior. |
gfxSpace (p) | Gets the texture of the spob in space. |
hostile (spb) | Checks to see if a spob currently has the hostile flag set. |
known (p) | Checks to see if a spob is known by the player. |
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. |
name (p) | Gets the spob's translated name. |
nameRaw (p) | Gets the spob's raw (untranslated) name. |
outfitsSold (p) | Gets the outfits sold at a spob. |
population (p) | Gets the spob's population. |
pos (p) | Gets the position of the spob in the system. |
radius (p) | Gets the spob's radius. |
recordCommodityPriceAtTime (p, t) | Records commodity prices at a given time, adding to players stats. |
reputation (spb) | Gets the local reputation of the faction at a spob. |
services (p) | Checks for spob services. |
setHostile (spb) | Sets the hostile flag of a spob. |
setKnown (p[, b=false]) | Sets a spobs's known state. |
shipsSold (p) | Gets the ships sold at a spob. |
system (p) | Gets the system corresponding to a spob. |
tags (p[, tag=nil]) | Gets the spob tags. |
Functions
- __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
- 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()
- 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()
- 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 (O-class)".
Usage:
c = p:classLong()
- 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()
- 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).
- 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)
- exists (name)
-
Tries to get a spob.
Parameters:
- name string Name of the spob to get.
Returns:
-
Spob
The matching spob.
- 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()
- flags (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
- 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
- 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.
- 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
- 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.
- 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
- 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()
- 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.
- 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()
- 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.
- 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()
- 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.
- 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()
- 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).
- population (p)
-
Gets the spob's population.
Parameters:
- p Spob Spob to get the population of.
Returns:
-
number
The spob's population.
- 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()
- 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()
- 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 )
- 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.
- 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.
- 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.
- 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.
- 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).
- 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.
- 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