Home

Module system

Lua system module. This module allows you to use the Star Systems from Lua. Typical example would be something like:
 cur = system.get() -- Gets current system
 sys = system.get( "Gamma Polaris" )
 

Functions

system.__eq (s, comp) Check systems for equality.
system.adjacentSystems (s, hidden) Gets all the adjacent systems to a system.
system.cur () Gets the current system.
system.faction (s) Gets system faction.
system.get (param) Gets a system.
system.getAll () Gets all the systems.
system.jumpDist (s, param, hidden) Gets jump distance from current system, or to another.
system.jumpPath (s, param, hidden) Gets jump path from current system, or to another.
system.jumps (s, exitonly) Gets all the jumps in a system.
system.known (s) Checks to see if a system is known by the player.
system.mrkAdd (str, v) Adds a system marker.
system.mrkClear () Clears the system markers.
system.mrkRm (id) Removes a system marker.
system.name (s) Returns the system's name.
system.nebula (s) Gets the system's nebula parameters.
system.planets (s) Gets the planets in a system.
system.presence (s) Gets the presence in the system.
system.presences (s) Returns the factions that have presence in a system and their respective presence values.
system.radius (s) Gets the radius of the system.
system.setKnown (s, b, r) Sets a system's known state.


Functions

system.__eq (s, comp)
Check systems for equality. Allows you to use the '=' operator in Lua with systems.

Parameters

  • s: System comparing.
  • comp: System to compare against.

Usage:

if sys == system.get( "Draygar" ) then -- Do something

Return value:

true if both systems are the same.
system.adjacentSystems (s, hidden)
Gets all the adjacent systems to a system.

Parameters

  • s: System to get adjacent systems of.
  • hidden: Whether or not to show hidden jumps also.

Usage:

for _,s in ipairs( sys:adjacentSystems() ) do -- Iterate over adjacent systems.

Return value:

An ordered table with all the adjacent systems.
system.cur ()
Gets the current system.

Usage:

sys = system.cur() -- Gets the current system

Return value:

Current system.
system.faction (s)
Gets system faction.

Parameters

  • s: System to get the faction of.

Return value:

The dominant faction in the system.
system.get (param)
Gets a system. Behaves differently depending on what you pass as param:
- string : Gets the system by name.
- planet : Gets the system by planet.

Parameters

  • param: Read description for details.

Usage

  • sys = system.get( p ) -- Gets system where planet 'p' is located.
  • sys = system.get( "Gamma Polaris" ) -- Gets the system by name.

Return value:

System metatable matching param.
system.getAll ()
Gets all the systems.

Return value:

A list of all the systems.
system.jumpDist (s, param, hidden)
Gets jump distance from current system, or to another. Does different things depending on the parameter type: - nil : Gets distance from current system. - string : Gets distance from system matching name. - system : Gets distance from system

Parameters

  • s: System to get distance from.
  • param: See description.
  • hidden: Whether or not to consider hidden jumps.

Usage

  • d = sys:jumpDist() -- Distance from current system.
  • d = sys:jumpDist( "Draygar" ) -- Distance from system Draygar.
  • d = sys:jumpDist( another_sys ) -- Distance from system another_sys.

Return value:

Number of jumps to system.
system.jumpPath (s, param, hidden)
Gets jump path from current system, or to another. Does different things depending on the parameter type: - nil : Gets path from current system. - string : Gets path from system matching name. - system : Gets path from system

Parameters

  • s: System to get path from.
  • param: See description.
  • hidden: Whether or not to consider hidden jumps.

Usage

  • jumps = sys:jumpPath() -- Path to current system.
  • jumps = sys:jumpPath( "Draygar" ) -- Path from current sys to Draygar.
  • jumps = system.jumpPath( "Draygar", another_sys ) -- Path from Draygar to another_sys.

Return value:

Table of jumps.
system.jumps (s, exitonly)
Gets all the jumps in a system.

Parameters

  • s: System to get the jumps of.
  • exitonly: Whether to exclude exit-only jumps (default false).

Usage:

for _,s in ipairs( sys:jumps() ) do -- Iterate over jumps.

Return value:

An ordered table with all the jumps.
system.known (s)
Checks to see if a system is known by the player.

Parameters

  • s: System to check if the player knows.

Usage:

b = s:known()

Return value:

true if the player knows the system.
system.mrkAdd (str, v)
Adds a system marker.

Parameters

  • str: String to display next to marker.
  • v: Position to display marker at.

Usage:

mrk_id = system.mrkAdd( "Hello", vec2.new( 50, 30 ) ) -- Creates a marker at (50,30)

Return value:

The id of the marker.
system.mrkClear ()
Clears the system markers. This can be dangerous and clash with other missions, do not try this at home kids.
system.mrkRm (id)
Removes a system marker.

Parameters

  • id: ID of the marker to remove.

Usage:

system.mrkRm( mrk_id ) -- Removes a marker by mrk_id
system.name (s)
Returns the system's name.

Parameters

  • s: System to get name of.

Usage:

name = sys:name()

Return value:

The name of the system.
system.nebula (s)
Gets the system's nebula parameters.

Parameters

  • s: System to get nebula parameters from.

Usage:

density, volatility = sys:nebula()

Return value:

The density and volatility of the system.
system.planets (s)
Gets the planets in a system.

Parameters

  • s: System to get planets of

Usage

  • for key, planet in ipairs( sys:planets() ) do -- Iterate over planets in system
  • if #sys:planets() > 0 then -- System has planets

Return value:

A table with all the planets
system.presence (s)
Gets the presence in the system. Possible parameters are besides a faction:
- "all": Gets the sum of all the presences.
- "friendly": Gets the sum of all the friendly presences.
- "hostile": Gets the sum of all the hostile presences.
- "neutral": Gets the sum of all the neutral presences.

Parameters

  • s: System to get presence level of.

Usage

  • p = sys:presence( f ) -- Gets the presence of a faction f
  • p = sys:presence( "all" ) -- Gets the sum of all the presences
  • if sys:presence("friendly") > sys:presence("hostile") then -- Checks to see if the system is dominantly friendly

Return value:

The presence level in sys (absolute value).
system.presences (s)
Returns the factions that have presence in a system and their respective presence values.

Parameters

  • s: System to get the factional presences of.

Usage

  • if sys:presences()["Empire"] then -- Checks to see if Empire has ships in the system
  • if sys:presences()[faction.get("Pirate")] then -- Checks to see if the Pirates have ships in the system

Return value:

A table with the factions that have presence in the system.
system.radius (s)
Gets the radius of the system. This is the radius of the circle which all the default jumps will be on.

Parameters

  • s: System to get the radius of.

Usage:

r = s:radius()

Return value:

The radius of the system.
system.setKnown (s, b, r)
Sets a system's known state.

Parameters

  • s: System to set known.
  • b: Whether or not to set as known (defaults to false).
  • r: Whether or not to iterate over the system's assets and jump points (defaults to false).

Usage:

s:setKnown( false ) -- Makes system unknown.

Valid XHTML 1.0!