![]() |
naev 0.12.6
|
Lua system module. More...
#include "nlua_system.h"#include "array.h"#include "gatherable.h"#include "land_outfits.h"#include "map.h"#include "map_overlay.h"#include "nlua_commodity.h"#include "nlua_faction.h"#include "nlua_jump.h"#include "nlua_spob.h"#include "nlua_vec2.h"#include "nluadef.h"#include "space.h"
Go to the source code of this file.
Functions | |
| static int | systemL_cur (lua_State *L) |
| Gets the current system. | |
| static int | systemL_get (lua_State *L) |
| Gets a system. | |
| static int | systemL_getAll (lua_State *L) |
| Gets all the systems. Lua return parameter: {System,...} A list of all the systems. | |
| static int | systemL_eq (lua_State *L) |
| Check systems for equality. | |
| static int | systemL_name (lua_State *L) |
| Returns the system's translated name. | |
| static int | systemL_nameRaw (lua_State *L) |
| Returns the system's raw (untranslated) name. | |
| static int | systemL_position (lua_State *L) |
| Returns the position of the system. | |
| static int | systemL_faction (lua_State *L) |
| Gets system faction. | |
| static int | systemL_background (lua_State *L) |
| Gets system background. | |
| static int | systemL_nebula (lua_State *L) |
| Gets the system's nebula parameters. | |
| static int | systemL_interference (lua_State *L) |
| Gets the system's interference level. | |
| static int | systemL_jumpdistance (lua_State *L) |
| Gets jump distance from current system, or to another. | |
| static int | systemL_jumpPath (lua_State *L) |
| Gets jump path from current system, or to another. | |
| static int | systemL_adjacent (lua_State *L) |
| Gets all the adjacent systems to a system. | |
| static int | systemL_jumps (lua_State *L) |
| Gets all the jumps in a system. | |
| static int | systemL_asteroidFields (lua_State *L) |
| Gets all the asteroid fields in a system. | |
| static int | systemL_addGatherable (lua_State *L) |
| Adds a gatherable object. | |
| static int | systemL_presences (lua_State *L) |
| Returns the factions that have presence in a system and their respective presence values. Faction names are internal – can be passed to other functions as a faction identifier, but should not be shown to the user without being translated by _(). | |
| static int | systemL_spobs (lua_State *L) |
| Gets the spobs in a system. | |
| static int | systemL_presence (lua_State *L) |
| Gets the presence in the system. | |
| static int | systemL_radius (lua_State *L) |
| Gets the radius of the system. | |
| static int | systemL_isknown (lua_State *L) |
| Checks to see if a system is known by the player. | |
| static int | systemL_setknown (lua_State *L) |
| Sets a system's known state. | |
| static int | systemL_hidden (lua_State *L) |
| Checks to see if a system is hidden by the player. | |
| static int | systemL_setHidden (lua_State *L) |
| Sets a system to be hidden to the player. | |
| static int | systemL_markerClear (lua_State *L) |
| Clears the system markers. | |
| static int | systemL_markerAdd (lua_State *L) |
| Adds a system marker. | |
| static int | systemL_markerRm (lua_State *L) |
| Removes a system marker. | |
| static int | systemL_reputation (lua_State *L) |
| Gets the stored local reputation of a system. | |
| static int | systemL_setReputation (lua_State *L) |
| Sets the stored local reputation of a system. | |
| static int | systemL_tags (lua_State *L) |
| Gets the system tags. | |
| int | nlua_loadSystem (nlua_env env) |
| Loads the system library. | |
| LuaSystem | lua_tosystem (lua_State *L, int ind) |
| Lua system module. | |
| LuaSystem | luaL_checksystem (lua_State *L, int ind) |
| Gets system at index raising an error if type doesn't match. | |
| StarSystem * | luaL_validsystem (lua_State *L, int ind) |
| Gets system (or system name) at index raising an error if type doesn't match. | |
| LuaSystem * | lua_pushsystem (lua_State *L, LuaSystem sys) |
| Pushes a system on the stack. | |
| int | lua_issystem (lua_State *L, int ind) |
| Checks to see if ind is a system. | |
Variables | |
| static const luaL_Reg | system_methods [] |
Lua system module.
Definition in file nlua_system.c.
| int lua_issystem | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a system.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 198 of file nlua_system.c.
| LuaSystem * lua_pushsystem | ( | lua_State * | L, |
| LuaSystem | sys ) |
Pushes a system on the stack.
| L | Lua state to push system onto. |
| sys | System to push. |
Definition at line 182 of file nlua_system.c.
| LuaSystem lua_tosystem | ( | lua_State * | L, |
| int | ind ) |
Lua system module.
This module allows you to use the Star Systems from Lua.
Typical example would be something like:
Lua module: system
Gets system at index.
| L | Lua state to get system from. |
| ind | Index position of system. |
Definition at line 128 of file nlua_system.c.
| LuaSystem luaL_checksystem | ( | lua_State * | L, |
| int | ind ) |
Gets system at index raising an error if type doesn't match.
| L | Lua state to get system from. |
| ind | Index position of system. |
Definition at line 139 of file nlua_system.c.
| StarSystem * luaL_validsystem | ( | lua_State * | L, |
| int | ind ) |
Gets system (or system name) at index raising an error if type doesn't match.
| L | Lua state to get system from. |
| ind | Index position of system. |
Definition at line 155 of file nlua_system.c.
| int nlua_loadSystem | ( | nlua_env | env | ) |
Loads the system library.
| env | Environment to load system library into. |
Definition at line 102 of file nlua_system.c.
|
static |
Adds a gatherable object.
Lua usage parameter: i = system.addGatherable( "Gold", 5, vec2.new(0,0), vec2.new(0,0) ) – creates 5 tons of gold at the origin
Lua function parameter: string commodity name of the commodity. Lua function parameter: int nb quantity of commodity in the gatherable . Lua function parameter:[opt=vec2.new(0,0)] Vec2 pos position of the gatherable. Lua function parameter:[opt=vec2.new(0,0)] Vec2 vel velocity of the gatherable. Lua function parameter:[opt] number lifelength Lifelength of the gatherable in seconds. Lua function parameter:[opt=false] boolean If true, the gatherable can only be gathered by player. Lua return parameter: int i Id of the created gatherable object.
| L | Lua State |
Lua function: addGatherable
Definition at line 672 of file nlua_system.c.
|
static |
Gets all the adjacent systems to a system.
Lua usage parameter: for i, s in ipairs( sys:adjacentSystems() ) do – Iterate over adjacent systems.
Lua function parameter: System s System to get adjacent systems of. Lua function parameter:[opt=false] boolean hidden Whether or not to show hidden jumps also. Lua return parameter: {System,...} An ordered table with all the adjacent systems.
| L | Lua State |
Lua function: adjacentSystems
Definition at line 563 of file nlua_system.c.
|
static |
Gets all the asteroid fields in a system.
Lua usage parameter: for i, s in ipairs( sys:asteroidFields() ) do – Iterate over asteroid fields
Lua function parameter: System s System to get the asteroid fields of. Lua return parameter: {Table,...} An ordered table with all the asteroid fields.
| L | Lua State |
Lua function: asteroidFields
Definition at line 631 of file nlua_system.c.
|
static |
Gets system background.
Lua function parameter: System s System to get the background of. Lua return parameter: string|nil The background of the system or nil for default.
| L | Lua State |
Lua function: background
Definition at line 387 of file nlua_system.c.
|
static |
Gets the current system.
Lua usage parameter: sys = system.cur() – Gets the current system
Lua return parameter: System Current system.
| L | Lua State |
Lua function: cur
Definition at line 222 of file nlua_system.c.
|
static |
Check systems for equality.
Allows you to use the '==' operator in Lua with systems.
Lua usage parameter: if sys == system.get( "Draygar" ) then – Do something
Lua function parameter: System s System comparing. Lua function parameter: System comp System to compare against. Lua return parameter: boolean true if both systems are the same.
| L | Lua State |
Lua function: __eq
Definition at line 298 of file nlua_system.c.
|
static |
Gets system faction.
Lua function parameter: System s System to get the faction of. Lua return parameter: Faction The dominant faction in the system.
| L | Lua State |
Lua function: faction
Definition at line 371 of file nlua_system.c.
|
static |
Gets a system.
Behaves differently depending on what you pass as param:
Lua usage parameter: sys = system.get( p ) – Gets system where spob 'p' is located. Lua usage parameter: sys = system.get( "Gamma Polaris" ) – Gets the system by name.
Lua function parameter: string|Spob param Read description for details. Lua return parameter: System System matching param.
| L | Lua State |
Lua function: get
Definition at line 242 of file nlua_system.c.
|
static |
Gets all the systems. Lua return parameter: {System,...} A list of all the systems.
| L | Lua State |
Lua function: getAll
Definition at line 275 of file nlua_system.c.
|
static |
Checks to see if a system is hidden by the player.
Lua usage parameter: b = s:hidden()
Lua function parameter: System s System to check if the player knows. Lua return parameter: boolean true if the player knows the system.
| L | Lua State |
Lua function: hidden
Definition at line 916 of file nlua_system.c.
|
static |
Gets the system's interference level.
Lua function parameter: System s System to get interference of. Lua return parameter: number The amount of interference (in percent).
| L | Lua State |
Lua function: interference
Definition at line 422 of file nlua_system.c.
|
static |
Checks to see if a system is known by the player.
Lua usage parameter: b = s:known()
Lua function parameter: System s System to check if the player knows. Lua return parameter: boolean true if the player knows the system.
| L | Lua State |
Lua function: known
Definition at line 853 of file nlua_system.c.
|
static |
Gets jump distance from current system, or to another.
Does different things depending on the parameter type:
Lua usage parameter: d = sys:jumpDist() – Distance the current system to sys. Lua usage parameter: d = sys:jumpDist( "Draygar" ) – Distance from sys to system Draygar. Lua usage parameter: d = sys:jumpDist( another_sys ) – Distance from sys to another_sys.
Lua function parameter: System s Starting system. Lua function parameter: nil|string|Goal system param See description. Lua function parameter:[opt=false] boolean hidden Whether or not to consider hidden jumps. Lua function parameter:[opt=false] boolean known Whether or not to consider only jumps known by the player. Lua return parameter: number Number of jumps to system or math.huge if no path found.
| L | Lua State |
Lua function: jumpDist
Definition at line 451 of file nlua_system.c.
|
static |
Gets jump path from current system, or to another.
Does different things depending on the parameter type:
Lua usage parameter: jumps = sys:jumpPath( system.cur() ) – Path from sys to current system. Lua usage parameter: jumps = sys:jumpPath( "Draygar" ) – Path from sys to Draygar. Lua usage parameter: jumps = system.jumpPath( "Draygar", another_sys ) – Path from Draygar to another_sys.
Lua function parameter: System s Starting system. Lua function parameter: System goal Goal system param See description. Lua function parameter:[opt=false] boolean hidden Whether or not to consider hidden jumps. Lua return parameter: {Jump,...} Table of jumps.
| L | Lua State |
Lua function: jumpPath
Definition at line 510 of file nlua_system.c.
|
static |
Gets all the jumps in a system.
Lua usage parameter: for i, s in ipairs( sys:jumps() ) do – Iterate over jumps.
Lua function parameter: System s System to get the jumps of. Lua function parameter:[opt=false] boolean exitonly Whether to exclude exit-only jumps. Lua return parameter: {Jump,...} An ordered table with all the jumps.
| L | Lua State |
Lua function: jumps
Definition at line 598 of file nlua_system.c.
|
static |
Adds a system marker.
Lua usage parameter: mrk_id = system.markerAdd( vec2.new( 50, 30 ), "Hello" ) – Creates a marker at (50,30)
Lua function parameter: Vec2 v Position to display marker at. Lua function parameter:[opt] string str String to display next to marker. Lua function parameter:[opt] number If specified, changes the marker to circle type marker and specifies the radius of the circle to use. Lua return parameter: number The id of the marker.
| L | Lua State |
Lua function: markerAdd
Definition at line 973 of file nlua_system.c.
|
static |
Clears the system markers.
This can be dangerous and clash with other missions, do not try this at home kids.
Lua usage parameter: system.markerClear()
| L | Lua State |
Lua function: markerClear
Definition at line 953 of file nlua_system.c.
|
static |
Removes a system marker.
Lua usage parameter: system.markerRm( mrk_id ) – Removes a marker by mrk_id
Lua function parameter: number id ID of the marker to remove.
| L | Lua State |
Lua function: markerRm
Definition at line 1002 of file nlua_system.c.
|
static |
Returns the system's translated name.
This translated name should be used for display purposes (e.g. messages). It cannot be used as an identifier for the system; for that, use system.nameRaw() instead.
Lua usage parameter: name = sys:name() – Equivalent to _(sys:nameRaw())
Lua function parameter: System s System to get the translated name of. Lua return parameter: string The translated name of the system.
| L | Lua State |
Lua function: name
Definition at line 323 of file nlua_system.c.
|
static |
Returns the system's raw (untranslated) name.
This untranslated name should be used for identification purposes (e.g. can be passed to system.get()). It should not be used directly for display purposes without manually translating it with _().
Lua usage parameter: name = sys:nameRaw()
Lua function parameter: System s System to get the raw name of. Lua return parameter: string The raw name of the system.
| L | Lua State |
Lua function: nameRaw
Definition at line 357 of file nlua_system.c.
|
static |
Gets the system's nebula parameters.
Lua usage parameter: density, volatility = sys:nebula()
Lua function parameter: System s System to get nebula parameters from. Lua return parameter: number The density of the system. Lua return parameter: number The amount of nebula damage done per second.
| L | Lua State |
Lua function: nebula
Definition at line 406 of file nlua_system.c.
|
static |
Returns the position of the system.
Lua function parameter: System s System to get position of. Lua return parameter: vec2 Position of the system.
| L | Lua State |
Lua function: pos
Definition at line 337 of file nlua_system.c.
|
static |
Gets the presence in the system.
Possible parameters are besides a faction:
Lua usage parameter: p = sys:presence( f ) – Gets the presence of a faction f Lua usage parameter: p = sys:presence( "all" ) – Gets the sum of all the presences Lua usage parameter: if sys:presence("friendly") > sys:presence("hostile") then – Checks to see if the system is dominantly friendly
Lua function parameter: System s System to get presence level of. Lua return parameter: number The presence level in sys (absolute value).
| L | Lua State |
Lua function: presence
Definition at line 769 of file nlua_system.c.
|
static |
Returns the factions that have presence in a system and their respective presence values. Faction names are internal – can be passed to other functions as a faction identifier, but should not be shown to the user without being translated by _().
Lua usage parameter: if sys:presences()["Empire"] then – Checks to see if Empire has ships in the system Lua usage parameter: if sys:presences()[faction.get("Dvaered"):nameRaw()] then – Checks to see if the Dvaered have ships in the system
Lua function parameter: System s System to get the factional presences of. Lua return parameter: {Faction,...} A table with the factions that have presence in the system.
| L | Lua State |
Lua function: presences
Definition at line 710 of file nlua_system.c.
|
static |
Gets the radius of the system.
This is the radius of the circle which all the default jumps will be on.
Lua usage parameter: r = s:radius()
Lua function parameter: System s System to get the radius of. Lua return parameter: number The radius of the system.
| L | Lua State |
Lua function: radius
Definition at line 837 of file nlua_system.c.
|
static |
Gets the stored local reputation of a system.
Lua function parameter: System s System to get the stored local reputation of. Lua function parameter:[opt=nil] Faction f Faction to get reputation of or nil to get the local reputation of all factions in the system. Lua return parameter: number|table|nil Either a number if the faction has a reputation in the system, a table if the faction wasn't set, or nil if nothing was found.
| L | Lua State |
Lua function: reputation
Definition at line 1020 of file nlua_system.c.
|
static |
Sets a system to be hidden to the player.
Lua usage parameter: s:setHidden( true )
Lua function parameter: System s System to check if the player knows. Lua function parameter: boolean hide Whether or not to hide the system.
| L | Lua State |
Lua function: hidden
Definition at line 932 of file nlua_system.c.
|
static |
Sets a system's known state.
Lua usage parameter: s:setKnown( false ) – Makes system unknown. Lua function parameter: System s System to set known. Lua function parameter:[opt=false] boolean b Whether or not to set as known. Lua function parameter:[opt=false] boolean r Whether or not to iterate over the system's spobs and jump points.
| L | Lua State |
Lua function: setKnown
Definition at line 870 of file nlua_system.c.
|
static |
Sets the stored local reputation of a system.
Lua function parameter: System s System to set the stored local reputation of. Lua function parameter: Faction f Faction to set the local reputation of. Lua function parameter: number value Value to set the local reputation to.
| L | Lua State |
Lua function: setReputation
Definition at line 1052 of file nlua_system.c.
|
static |
Gets the spobs in a system.
Lua usage parameter: for key, spob in ipairs( sys:spobs() ) do – Iterate over spobs in system Lua usage parameter: if #sys:spobs() > 0 then – System has spobs
Lua function parameter: System s System to get spobs of Lua return parameter: {Spob,...} A table with all the spobs
| L | Lua State |
Lua function: spobs
Definition at line 739 of file nlua_system.c.
|
static |
Gets the system tags.
Lua usage parameter: if system.cur():tags["fancy"] then – Has "fancy" tag
Lua function parameter: System s System to get tags of. Lua function parameter:[opt=nil] string tag Tag to check if exists. Lua return parameter: table|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.
| L | Lua State |
Lua function: tags
Definition at line 1076 of file nlua_system.c.
|
static |
System metatable methods.
Definition at line 61 of file nlua_system.c.