![]() |
naev 0.10.4
|
Lua spob module. More...
#include "nlua_spob.h"#include "array.h"#include "land.h"#include "land_outfits.h"#include "log.h"#include "map.h"#include "map_overlay.h"#include "nlua_colour.h"#include "nlua_commodity.h"#include "nlua_faction.h"#include "nlua_outfit.h"#include "nlua_ship.h"#include "nlua_system.h"#include "nlua_tex.h"#include "nlua_time.h"#include "nlua_vec2.h"#include "nluadef.h"#include "nmath.h"#include "nstring.h"#include "rng.h"Go to the source code of this file.
Functions | |
| static int | spobL_cur (lua_State *L) |
| Gets the current spob - MUST BE LANDED. More... | |
| static int | spobL_get (lua_State *L) |
| Gets a spob. More... | |
| static int | spobL_getS (lua_State *L) |
| Gets a spob and its corresponding system. More... | |
| static int | spobL_getLandable (lua_State *L) |
| Gets a spob only if it's landable. More... | |
| static int | spobL_getAll (lua_State *L) |
| Gets all the spobs. Lua function parameter: boolean all_spob Whether or not to get all Spob, including those that may not be located in a system at the time. Lua return parameter: {Spob,...} An ordered list of all the spobs. More... | |
| static int | spobL_system (lua_State *L) |
| Gets the system corresponding to a spob. Lua function parameter: Spob p Spob to get system of. Lua return parameter: System|nil The system to which the spob belongs or nil if it has none. More... | |
| static int | spobL_eq (lua_State *L) |
| You can use the '==' operator within Lua to compare spobs with this. More... | |
| static int | spobL_name (lua_State *L) |
| Gets the spob's translated name. More... | |
| static int | spobL_nameRaw (lua_State *L) |
| Gets the spob's raw (untranslated) name. More... | |
| static int | spobL_population (lua_State *L) |
| Gets the spob's population. More... | |
| static int | spobL_radius (lua_State *L) |
| Gets the spob's radius. More... | |
| static int | spobL_faction (lua_State *L) |
| Gets the spob's faction. More... | |
| static int | spobL_colour (lua_State *L) |
| Gets a spob's colour based on its friendliness or hostility to the player. More... | |
| static int | spobL_class (lua_State *L) |
| Gets the spob's class. More... | |
| static int | spobL_classLong (lua_State *L) |
| Gets the spob's class in long human-readable format already translated. More... | |
| static int | spobL_position (lua_State *L) |
| Gets the position of the spob in the system. More... | |
| static int | spobL_services (lua_State *L) |
| Checks for spob services. More... | |
| static int | spobL_flags (lua_State *L) |
| Checks for spob flags. More... | |
| static int | spobL_canland (lua_State *L) |
| Gets whether or not the player can land on the spob (or bribe it). More... | |
| static int | spobL_landOverride (lua_State *L) |
| Lets player land on a spob no matter what. The override lasts until the player jumps or lands. More... | |
| static int | spobL_getLandOverride (lua_State *L) |
| Gets the land override status for a spob. More... | |
| static int | spobL_gfxSpace (lua_State *L) |
| Gets the texture of the spob in space. More... | |
| static int | spobL_gfxExterior (lua_State *L) |
| Gets the texture of the spob in exterior. More... | |
| static int | spobL_shipsSold (lua_State *L) |
| Gets the ships sold at a spob. More... | |
| static int | spobL_outfitsSold (lua_State *L) |
| Gets the outfits sold at a spob. More... | |
| static int | spobL_commoditiesSold (lua_State *L) |
| Gets the commodities sold at a spob. More... | |
| static int | spobL_isBlackMarket (lua_State *L) |
| Checks to see if a spob is a black market. More... | |
| static int | spobL_isKnown (lua_State *L) |
| Checks to see if a spob is known by the player. More... | |
| static int | spobL_setKnown (lua_State *L) |
| Sets a spobs's known state. More... | |
| static int | spobL_recordCommodityPriceAtTime (lua_State *L) |
| Records commodity prices at a given time, adding to players stats. More... | |
| static int | spobL_tags (lua_State *L) |
| Gets the spob tags. More... | |
| int | nlua_loadSpob (nlua_env env) |
| Loads the spob library. More... | |
| LuaSpob | lua_tospob (lua_State *L, int ind) |
| This module allows you to handle the spobs from Lua. More... | |
| LuaSpob | luaL_checkspob (lua_State *L, int ind) |
| Gets spob at index raising an error if isn't a spob. More... | |
| Spob * | luaL_validspob (lua_State *L, int ind) |
| Gets a spob directly. More... | |
| LuaSpob * | lua_pushspob (lua_State *L, LuaSpob spob) |
| Pushes a spob on the stack. More... | |
| int | lua_isspob (lua_State *L, int ind) |
| Checks to see if ind is a spob. More... | |
| static int | spobL_getBackend (lua_State *L, int system, int landable) |
Variables | |
| static const luaL_Reg | spob_methods [] |
Lua spob module.
Definition in file nlua_spob.c.
| int lua_isspob | ( | lua_State * | L, |
| int | ind | ||
| ) |
Checks to see if ind is a spob.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 207 of file nlua_spob.c.
| LuaSpob * lua_pushspob | ( | lua_State * | L, |
| LuaSpob | spob | ||
| ) |
Pushes a spob on the stack.
| L | Lua state to push spob into. |
| spob | Spob to push. |
Definition at line 192 of file nlua_spob.c.
| LuaSpob lua_tospob | ( | lua_State * | L, |
| int | ind | ||
| ) |
This module allows you to handle the spobs from Lua.
Generally you do something like:
Lua module: spob
Gets spob at index.
| L | Lua state to get spob from. |
| ind | Index position to find the spob. |
Definition at line 139 of file nlua_spob.c.
| LuaSpob luaL_checkspob | ( | lua_State * | L, |
| int | ind | ||
| ) |
Gets spob at index raising an error if isn't a spob.
| L | Lua state to get spob from. |
| ind | Index position to find the spob. |
Definition at line 150 of file nlua_spob.c.
| Spob * luaL_validspob | ( | lua_State * | L, |
| int | ind | ||
| ) |
Gets a spob directly.
| L | Lua state to get spob from. |
| ind | Index position to find the spob. |
Definition at line 164 of file nlua_spob.c.
| int nlua_loadSpob | ( | nlua_env | env | ) |
Loads the spob library.
| env | Environment to load spob library into. |
Definition at line 111 of file nlua_spob.c.
|
static |
Gets whether or not the player can land on the spob (or bribe it).
Lua usage parameter: can_land, can_bribe = p:canLand() Lua function parameter: Spob p Spob to get land and bribe status of. Lua return parameter: boolean The land status of the spob.
| L | Lua State |
Lua function: canLand
Definition at line 697 of file nlua_spob.c.
|
static |
Gets the spob's class.
Usually classes are characters for spobs and numbers for stations.
Lua usage parameter: c = p:class() Lua function parameter: Spob p Spob to get the class of. Lua return parameter: string The class of the spob in a one char identifier.
| L | Lua State |
Lua function: class
Definition at line 603 of file nlua_spob.c.
|
static |
Gets the spob's class in long human-readable format already translated.
Lua usage parameter: c = p:classLong() Lua function parameter: Spob p Spob to get the class of. Lua return parameter: string The class of the spob in descriptive form such as "Pelagic".
| L | Lua State |
Lua function: classLong
Definition at line 618 of file nlua_spob.c.
|
static |
Gets a spob's colour based on its friendliness or hostility to the player.
Lua usage parameter: col = p:colour()
Lua function parameter: Pilot p Spob to get the colour of. Lua return parameter: Colour The spob's colour.
| L | Lua State |
Lua function: colour
Definition at line 584 of file nlua_spob.c.
|
static |
Gets the commodities sold at a spob.
Lua function parameter: Pilot p Spob to get commodities sold at. Lua return parameter: {Commodity,...} An ordered table containing all the commodities sold (empty if none sold).
| L | Lua State |
Lua function: commoditiesSold
Definition at line 854 of file nlua_spob.c.
|
static |
Gets the current spob - MUST BE LANDED.
Lua usage parameter: p,s = spob.cur() – Gets current spob (assuming landed)
Lua return parameter: Spob The spob the player is landed on. Lua return parameter: System The system it is in.
| L | Lua State |
Lua function: cur
Definition at line 232 of file nlua_spob.c.
|
static |
You can use the '==' operator within Lua to compare spobs with this.
Lua usage parameter: if p.__eq( spob.get( "Anecu" ) ) then – Do something Lua usage parameter: if p == spob.get( "Anecu" ) then – Do something Lua function parameter: Spob p Spob comparing. Lua function parameter: Spob comp spob to compare against. Lua return parameter: boolean true if both spobs are the same.
| L | Lua State |
Lua function: __eq
Definition at line 476 of file nlua_spob.c.
|
static |
Gets the spob's faction.
Lua usage parameter: f = p:faction() Lua function parameter: Spob p Spob to get the faction of. Lua return parameter: Faction The spob's faction, or nil if it has no faction.
| L | Lua State |
Lua function: faction
Definition at line 566 of file nlua_spob.c.
|
static |
Checks for spob flags.
Possible services are:
Lua usage parameter: if p:flags()["nomissionspawn"] then – Spob doesn't spawn missions Lua function parameter: Spob p Spob to get the services of. Lua return parameter: table Table containing all the services.
| L | Lua State |
Lua function: services
Definition at line 677 of file nlua_spob.c.
|
static |
Gets a spob.
Possible values of param:
Lua usage parameter: p = spob.get( "Anecu" ) – Gets spob by name Lua usage parameter: p = spob.get( faction.get( "Empire" ) ) – Gets random Empire spob Lua usage parameter: p = spob.get(true) – Gets completely random spob Lua usage parameter: p = spob.get( { faction.get("Empire"), faction.get("Dvaered") } ) – Random spob belonging to Empire or Dvaered Lua function parameter: boolean|Faction|string|table param See description. Lua return parameter: Spob The matching spob.
| L | Lua State |
Lua function: get
Definition at line 382 of file nlua_spob.c.
|
static |
Gets all the spobs. Lua function parameter: boolean all_spob Whether or not to get all Spob, including those that may not be located in a system at the time. Lua return parameter: {Spob,...} An ordered list of all the spobs.
| L | Lua State |
Lua function: getAll
Definition at line 433 of file nlua_spob.c.
|
static |
Definition at line 245 of file nlua_spob.c.
|
static |
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.
Lua function parameter: boolean|Faction|string|table param See spob.get() description. Lua return parameter: Spob The matching spob, if it is landable. Lua return parameter: System The system it is in.
| L | Lua State |
Lua function: getLandable
Definition at line 422 of file nlua_spob.c.
|
static |
Gets the land override status for a spob.
Lua usage parameter: if p:getLandOverride() then – Player can definitely land. Lua function parameter: Spob p Spob to check. Lua return parameter: b Whether or not the player is always allowed to land.
| L | Lua State |
Lua function: getLandOverride
Definition at line 735 of file nlua_spob.c.
|
static |
Gets a spob and its corresponding system.
Possible values of param:
Lua usage parameter: p,s = spob.get( "Anecu" ) – Gets spob by name Lua usage parameter: p,s = spob.get( faction.get( "Empire" ) ) – Gets random Empire spob Lua usage parameter: p,s = spob.get(true) – Gets completely random spob Lua usage parameter: p,s = spob.get( { faction.get("Empire"), faction.get("Dvaered") } ) – Random spob belonging to Empire or Dvaered Lua function parameter: boolean|Faction|string|table param See description. Lua return parameter: Spob The matching spob. Lua return parameter: System The system it is in.
| L | Lua State |
Lua function: getS
Definition at line 406 of file nlua_spob.c.
|
static |
Gets the texture of the spob in exterior.
Lua usage parameter: gfx = p:gfxExterior() Lua function parameter: Spob p Spob Spob to get texture of. Lua return parameter: Tex The exterior texture of the spob.
| L | Lua State |
Lua function: gfxExterior
Definition at line 789 of file nlua_spob.c.
|
static |
Gets the texture of the spob in space.
Lua usage parameter: gfx = p:gfxSpace() Lua function parameter: Spob p Spob to get texture of. Lua return parameter: Tex The space texture of the spob.
| L | Lua State |
Lua function: gfxSpace
Definition at line 765 of file nlua_spob.c.
|
static |
Checks to see if a spob is a black market.
Lua usage parameter: b = p:blackmarket()
Lua function parameter: Spob p Spob to check if it's a black market. Lua return parameter: boolean true if the spob is a black market.
| L | Lua State |
Lua function: blackmarket
Definition at line 878 of file nlua_spob.c.
|
static |
Checks to see if a spob is known by the player.
Lua usage parameter: b = p:known()
Lua function parameter: Spob p Spob to check if the player knows. Lua return parameter: boolean true if the player knows the spob.
| L | Lua State |
Lua function: known
Definition at line 894 of file nlua_spob.c.
|
static |
Lets player land on a spob no matter what. The override lasts until the player jumps or lands.
Lua usage parameter: p:landOverride( true ) – Spob can land on p now. Lua function parameter: Spob p Spob to forcibly allow the player to land on. Lua function parameter:[opt=false] boolean b Whether or not the player should be allowed to land, true enables, false disables override.
| L | Lua State |
Lua function: landOverride
Definition at line 713 of file nlua_spob.c.
|
static |
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.
Lua usage parameter: name = p:name() Lua function parameter: Spob p Spob to get the translated name of. Lua return parameter: string The translated name of the spob.
| L | Lua State |
Lua function: name
Definition at line 500 of file nlua_spob.c.
|
static |
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 _().
Lua usage parameter: name = p:nameRaw() Lua function parameter: Spob p Spob to get the raw name of. Lua return parameter: string The raw name of the spob.
| L | Lua State |
Lua function: nameRaw
Definition at line 519 of file nlua_spob.c.
|
static |
Gets the outfits sold at a spob.
Lua function parameter: Spob p Spob to get outfits sold at. Lua return parameter: {Outfit,...} An ordered table containing all the outfits sold (empty if none sold).
| L | Lua State |
Lua function: outfitsSold
Definition at line 831 of file nlua_spob.c.
|
static |
Gets the spob's population.
Lua function parameter: Spob p Spob to get the population of. Lua return parameter: number The spob's population.
| L | Lua State |
Lua function: population
Definition at line 533 of file nlua_spob.c.
|
static |
Gets the position of the spob in the system.
Lua usage parameter: v = p:pos() Lua function parameter: Spob p Spob to get the position of. Lua return parameter: Vec2 The position of the spob in the system.
| L | Lua State |
Lua function: pos
Definition at line 750 of file nlua_spob.c.
|
static |
Gets the spob's radius.
Lua usage parameter: radius = p:radius() Lua function parameter: Spob p Spob to get the radius of. Lua return parameter: number The spob's graphics radius.
| L | Lua State |
Lua function: radius
Definition at line 548 of file nlua_spob.c.
|
static |
Records commodity prices at a given time, adding to players stats.
Lua usage parameter: p:recordCommodityPriceAtTime( t ) Lua function parameter: Spob p Spob to record prices at Lua function parameter: ntime_t t Time at which to record prices.
| L | Lua State |
Lua function: recordCommodityPriceAtTime
Definition at line 938 of file nlua_spob.c.
|
static |
Checks for spob services.
Possible services are:
Lua usage parameter: if p:services()["refuel"] then – Spob has refuel service. Lua usage parameter: if p:services()["shipyard"] then – Spob has shipyard service. Lua function parameter: Spob p Spob to get the services of. Lua return parameter: table Table containing all the services.
| L | Lua State |
Lua function: services
Definition at line 645 of file nlua_spob.c.
|
static |
Sets a spobs's known state.
Lua usage parameter: p:setKnown( false ) – Makes spob unknown. Lua function parameter: Spob p Spob to set known. Lua function parameter:[opt=false] boolean b Whether or not to set as known.
| L | Lua State |
Lua function: setKnown
Definition at line 909 of file nlua_spob.c.
|
static |
Gets the ships sold at a spob.
Lua function parameter: Spob p Spob to get ships sold at. Lua return parameter: {Ship,...} An ordered table containing all the ships sold (empty if none sold).
| L | Lua State |
Lua function: shipsSold
Definition at line 808 of file nlua_spob.c.
|
static |
Gets the system corresponding to a spob. Lua function parameter: Spob p Spob to get system of. Lua return parameter: System|nil The system to which the spob belongs or nil if it has none.
| L | Lua State |
Lua function: system
Definition at line 454 of file nlua_spob.c.
|
static |
Gets the spob tags.
Lua usage parameter: if spob.cur():tags["fancy"] then – Has "fancy" tag
Lua function parameter: Spob p Spob to get tags of. Lua return parameter: table Table of tags where the name is the key and true is the value.
| L | Lua State |
Lua function: tags
Definition at line 955 of file nlua_spob.c.
|
static |
Spob metatable methods.
Definition at line 69 of file nlua_spob.c.