- 1 Scripting overview
- 1.1 Basic concepts
- 1.2 VoidExpanse Scripting API
- 1.3 Device scripts
- 1.4 Consumables scripting
Scripting naming convention
- String ID’s in mods can only contain alphanumeric characters and underscores. Any other characters are illegal.
- Use underscore for variables and properties.
- Use CamelCase for functions and methods.
- zxc_q - “q” in the variable always represents “quantity” or “number of ...”.
- zxc_id - “id” always means either a string id from a XML file if it is of the type of string, or if it is a uint then it is an entity (instance) id of some object.
- zxc_req - “req” always means “requirements”.
- All mods should prefix their variables, functions, classes, storage keys, etc with a key for isolation from other mods. An example of such a prefix would be “prf_” -> “prf_some_variable”, “prf_SomeFunction”.
Internal scripts (Overridable)
Main article: Internal scripts
These scripts are usually only called once and only in a particular situation. Each of these script files must exist in only one instance. If a new script is added the previous one will be overridden. Each of the script files must implement only one script action. Usually players should not modify these scripts unless they want to completely re-implement some game feature.
Global scripts (called in the world dynamically)
Main article: Global scripts
Global scripts are executed continuously during gameplay. For each event there could be many bound scripts. Also it is possible to create custom actions and subscribe to them. Please note: OnInit() method is executed only for Global and Internal scripts.
Main article: Object scripts
Object scripts are scripts attached to a particular game object. When that object starts an action, if a script has an appropriate handler for this action it will be executed.
VoidExpanse Scripting API
Library inclusion and scopes usage
include(libname.js); includes a library script into the current JS instance. Library scripts can also include other libraries (no echo effect will appear).
Allows modders to use functions and objects of these libraries in this particular script instance.
- Include directive must be the first lines in the script file (not necessarily, but preferably - to maintain order in scripts).
- All include directives must be before the first function declaration in the file.
using(scopename); allows modders to use a specific scope in a specific script. Scope name must be an existing scope name (see scopes below). Except for some specific scopes (like topic or npc), which are available only in specific places, like topic scripts or AI behaviors.
Each scope contains a number of functions available from it.
- VoidExpanse/scope-config (available: global)
- VoidExpanse/scope-script (available: global)
- VoidExpanse/scope-actions (available: global)
- VoidExpanse/scope-items (available: global)
- VoidExpanse/scope-server (available: global)
- VoidExpanse/scope-generator (available: global)
- VoidExpanse/scope-spawn (available: global)
- VoidExpanse/scope-station (available: global)
- VoidExpanse/scope-chat (available: global)
- VoidExpanse/scope-console (available: global)
- VoidExpanse/scope-storage (available: global)
- VoidExpanse/scope-game (available: global)
- VoidExpanse/scope-ship (available: global)
- VoidExpanse/scope-visual (available: global)
- VoidExpanse/scope-player (available: global)
- VoidExpanse/scope-topic (available: only in topics)
- VoidExpanse/scope-topics (available: global)
- VoidExpanse/scope-relations (available: global)
- VoidExpanse/scope-npc (available: global)
- VoidExpanse/scope-timer (available: global)
- VoidExpanse/scope-debug (available: global)
Main article: Device scripts
Devices uses effect scripts, which is similar to any object scripts, but uses it’s own special system of arguments. These scripts are shared between instances of the same device type, therefore global variables in these scripts are denied.
There are four possible functions for device script.
Main article: Consumables scripting
Consumables can be programmed with standard xml-values, but, in order to implement something special, one can use special techniques described in this article.
|VoidExpanse Modding (Edit template)|
Using mods: Installing and using mods