Module naev
Naev generic Lua bindings.
Functions
cache () | Gets the global Lua runtime cache. |
claimTest (params[, inclusive=false]) | Tests a claim of a system or strings. |
clock () | Gets the approximate CPU processing time. |
conf () | Gets the configuration information. |
confSet (name, value) | Sets configuration variables. |
date () | Equivalent to os.date from standard Lua. |
debugCollisions ([state=true]) | Toggles the collision polygons. |
debugTrails ([state=true]) | Toggles the trail emitters. |
difficulty (internal) | Gets information about the current difficulty setting. |
envs () | Gets a table with all the active Naev environments. |
eventReload (evtname) | Reloads an event's script, providing a convenient way to test and hopefully not corrupt the game's state. |
eventStart (evtname) | Starts an event, does not start check conditions. |
fps () | Gets the current game FPS as displayed to the player. |
hasTextInput () | Checks to see if text inputting is enabled. |
isPaused () | Checks to see if the game is paused. |
isSimulation () | Gets whether or not the universe is being simulated or not. |
keyDisableAll () | Disables all inputs. |
keyEnable (keyname[, enable=false]) | Disables or enables a specific keybinding. |
keyEnableAll () | Enables all inputs. |
keyGet (keyname) | Gets a human-readable name for the key bound to a function. |
language () | Gets the current language locale. |
lastplayed () | Gets how many days it has been since the player last played Naev. |
menuInfo ([window="main"]) | Opens the info menu window. |
menuSmall ([info=false[, options=false[, allowsave=false]]]) | Opens the small menu window. |
missionList () | Lists all the missions in the game. |
missionReload (misnname) | Reloads a mission's script, providing a convenient way to test and hopefully not corrupt the game's state. |
missionStart (misnname) | Starts a mission, does no check start conditions. |
missionTest (misnname) | Tests a missions conditionals to see if it can be started by the player. |
pause () | Pauses the game. |
plugins () | Gets the list of available plugins. |
quadtreeParams (max_elem, depth) | Modifies the Naev internal quadtree lookup parameters. |
setTextInput (enable, Text, Text, Text, Text) | Enables or disables text inputting. |
shadersReload () | Reloads all the Naev shaders excluding those created by the shader library. |
shipstats () | Gets the translated string corresponding to an in-game unit. |
ticks () | Gets the seconds since the program started running. |
ticksGame () | Gets the game seconds since the program started running. |
trigger (hookname, arg) | Triggers manually a hook stack. |
unit ([string=nil]) | Gets the translated string corresponding to an in-game unit. |
unpause () | Unpauses the game. |
version () | Gets the version of Naev and the save game. |
versionTest (v1, v2) | Tests two semver version strings. |
Functions
- cache ()
-
Gets the global Lua runtime cache. This is shared among all
environments and is cleared when the game is closed.
Returns:
-
table
The Lua global cache.
Usage:
c = naev.cache()
- claimTest (params[, inclusive=false])
-
Tests a claim of a system or strings.
Parameters:
- params System, String or {System,String...} Table of systems/strings to claim or a single system/string.
- inclusive boolean Whether or not to allow the claim to include other inclusive claims. Multiple missions/events can inclusively claim the same system, but only one system can exclusively claim it. (default false)
Returns:
-
boolean
true if it is possible to claim, false otherwise.
Usage:
if not naev.claimTest( { system.get("Gamma Polaris") } ) then print("Failed to claim!") end
- clock ()
-
Gets the approximate CPU processing time.
Returns:
-
number
Seconds elapsed since start of the process.
- conf ()
-
Gets the configuration information.
Returns:
-
table
Table of configuration values as they appear in the
configuration file.
- confSet (name, value)
-
Sets configuration variables. Note that not all are supported.
Parameters:
- date ()
- Equivalent to os.date from standard Lua.
- debugCollisions ([state=true])
-
Toggles the collision polygons.
Parameters:
- state boolean Whether or not to show the collision polygons. (default true)
- debugTrails ([state=true])
-
Toggles the trail emitters.
Parameters:
- state boolean Whether to set or unset markers. (default true)
Usage:
naev.debugTrails() -- Trail emitters are marked with crosses.
naev.debugTrails(false) -- Remove the markers.
- difficulty (internal)
-
Gets information about the current difficulty setting.
Parameters:
- internal boolean Whether or not to get values using the internal format, or a human readable format.
Returns:
- envs ()
-
Gets a table with all the active Naev environments.
Only available only debug builds.
Returns:
-
table
Unordered table containing all the environments.
- eventReload (evtname)
-
Reloads an event's script, providing a convenient way to test and
hopefully not corrupt the game's state. Use with caution, and only during
development as a way to get quicker feedback.
Parameters:
- evtname string Name of the event to start.
Returns:
-
boolean
true on success.
Usage:
naev.eventReload( "Some Event" )
- eventStart (evtname)
-
Starts an event, does not start check conditions.
Parameters:
- evtname string Name of the event to start.
Returns:
-
boolean
true on success.
Usage:
naev.eventStart( "Some Event" )
- fps ()
-
Gets the current game FPS as displayed to the player.
Returns:
-
number
Current FPS as displayed to the player.
- hasTextInput ()
-
Checks to see if text inputting is enabled.
Returns:
-
boolean
Whether or not text inputting is enabled.
- isPaused ()
-
Checks to see if the game is paused.
Returns:
-
boolean
Whether or not the game is currently paused.
- isSimulation ()
-
Gets whether or not the universe is being simulated or not.
Returns:
-
boolean
true if the world is being simulated.
- keyDisableAll ()
-
Disables all inputs.
Usage:
naev.keyDisableAll() -- Disables all inputs
- keyEnable (keyname[, enable=false])
-
Disables or enables a specific keybinding.
Use with caution, this can make the player get stuck.
Parameters:
- keyname string Name of the key to disable (for example "accel").
- enable boolean Whether to enable or disable. (default false)
Usage:
naev.keyEnable( "accel", false ) -- Disables the acceleration key
- keyEnableAll ()
-
Enables all inputs.
Usage:
naev.keyEnableAll() -- Enables all inputs
- keyGet (keyname)
-
Gets a human-readable name for the key bound to a function.
Parameters:
- keyname string Name of the keybinding to get value of. Valid values are listed in src/input.c: keybind_info.
Usage:
bindname = naev.keyGet( "accel" )
- language ()
-
Gets the current language locale.
Returns:
-
string
Current language locale (such as "en" for English, "de"
for German, or "ja" for Japanese).
- lastplayed ()
-
Gets how many days it has been since the player last played Naev.
Returns:
- number Number of days since the player last played.
- number Number of days since any of the save games were played.
- menuInfo ([window="main"])
-
Opens the info menu window.
Possible window targets are:
- "main" : Main window.
- "ship" : Ship info window.
- "weapons" : Weapon configuration window.
- "cargo" : Cargo view window.
- "missions" : Mission view window.
- "standings" : Standings view window.
Parameters:
- window string parameter indicating the tab to open at. (default "main")
Usage:
naev.menuInfo( "ship" ) -- Opens ship tab
- menuSmall ([info=false[, options=false[, allowsave=false]]])
-
Opens the small menu window.
Parameters:
- info boolean Show the info button. (default false)
- options boolean Show the options button. (default false)
- allowsave boolean Allow saving the game from the menu (either directly or by exiting the game from the menu). (default false)
Usage:
naev.menuSmall()
- missionList ()
-
Lists all the missions in the game.
Returns:
-
table
A table of all the missions in the game, each as a
table.
- missionReload (misnname)
-
Reloads a mission's script, providing a convenient way to test and
hopefully not corrupt the game's state. Use with caution, and only during
development as a way to get quicker feedback.
Parameters:
- misnname string Name of the mission to start.
Returns:
-
boolean
true on success.
Usage:
naev.missionReload( "Some Mission" )
- missionStart (misnname)
-
Starts a mission, does no check start conditions.
Parameters:
- misnname string Name of the mission to start.
Returns:
- boolean true if mission was either accepted, or started without misn.finish() getting called in create.
- boolean true whether or not the mission was accepted.
Usage:
naev.missionStart( "Some Mission" )
- missionTest (misnname)
-
Tests a missions conditionals to see if it can be started by the
player.
Note that this tests the Lua conditionals, not the create function, so it may be possible that even though naev.missionTest returns true, the player can still not start the mission.
Parameters:
- misnname string Name of the mission to test.
Returns:
-
boolean
true if the mission can be can be started, or false
otherwise.
Usage:
naev.missionTest( "Some Mission" )
- pause ()
- Pauses the game.
- plugins ()
-
Gets the list of available plugins.
Returns:
-
table
Table containing the list of plugins.
- quadtreeParams (max_elem, depth)
-
Modifies the Naev internal quadtree lookup parameters.
Parameters:
- max_elem number Maximum amount of elements to allow in a leaf node.
- depth number depth Maximum depth to allow.
- setTextInput (enable, Text, Text, Text, Text)
-
Enables or disables text inputting.
Parameters:
- enable boolean Whether text input events should be enabled.
- Text integer rectangle height.
- Text integer rectangle height.
- Text integer rectangle height.
- Text integer rectangle height.
- shadersReload ()
- Reloads all the Naev shaders excluding those created by the shader library.
- shipstats ()
-
Gets the translated string corresponding to an in-game unit.
- name: Name of the ship stat.
- display: Untranslated display name of the ship stat, which you use to show to the player.
- unit: Untranslated unit name (if applicable, otherwise nil).
- inverted: Boolean value whether or not negative is "better" for the player.
Returns:
-
Table
with all the ship stats information.
- ticks ()
-
Gets the seconds since the program started running.
Useful for doing timing on Lua functions.
Returns:
-
number
The seconds since the application started running.
- ticksGame ()
-
Gets the game seconds since the program started running.
These are modified by whatever speed up the player has.
Returns:
-
number
The seconds since the application started running.
- trigger (hookname, arg)
-
Triggers manually a hook stack. This is run deferred (next frame).
Meant mainly to be used with hook.custom, but can work with other hooks too
(if you know what you are doing).
Note This will trigger all hooks waiting on a stack.
Parameters:
- hookname string Name of the hook to be run.
- arg Parameter to pass to the hooks.
Usage:
naev.trigger( "my_event", data ) -- data will be passed to the receiving end
- unit ([string=nil])
-
Gets the translated string corresponding to an in-game unit.
strings if no parameter is passed.
Parameters:
- string str Name of the unit to get or nil to get a table with all of them. (default nil)
Returns:
-
Translated string corresponding to the unit or table of all
- unpause ()
-
Unpauses the game.
Can not be run while landed.
- version ()
-
Gets the version of Naev and the save game.
Returns:
Usage:
game_version, save_version = naev.version()
- versionTest (v1, v2)
-
Tests two semver version strings.
Parameters:
Returns:
-
number
Positive if v1 is newer or negative if v2 is newer.