<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.atomictorch.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tjmonk15</id>
	<title>AtomicTorchWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.atomictorch.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tjmonk15"/>
	<link rel="alternate" type="text/html" href="https://wiki.atomictorch.com/Special:Contributions/Tjmonk15"/>
	<updated>2026-05-30T11:39:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.atomictorch.com/index.php?title=VoidExpanse/scripting_api&amp;diff=250</id>
		<title>VoidExpanse/scripting api</title>
		<link rel="alternate" type="text/html" href="https://wiki.atomictorch.com/index.php?title=VoidExpanse/scripting_api&amp;diff=250"/>
		<updated>2014-07-25T03:27:02Z</updated>

		<summary type="html">&lt;p&gt;Tjmonk15: Grammar, punctuation, phrasing edits.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Scripting overview =&lt;br /&gt;
&lt;br /&gt;
== Basic concepts ==&lt;br /&gt;
Scripting is done via actions that custom scripts can subscribe to. There are a number of actions that are called by servers automatically, plus users can create their own actions and call them when needed. This also makes it possible for users to create scripting frameworks/libraries for others to use.&lt;br /&gt;
Each action has one argument (ΓÇ£argsΓÇ¥) that is a JavaScript object containing several properties depending on which action is being called. In some actions this ΓÇ£argsΓÇ¥ object can be empty. But either way, it allows for a unified format for all actions within the scripting system.&lt;br /&gt;
&lt;br /&gt;
=== Scripting naming convention ===&lt;br /&gt;
* String IDΓÇÖs in mods can only contain alphanumeric characters and underscores. Any other characters are illegal.&lt;br /&gt;
* Use underscore for variables and properties.&lt;br /&gt;
* Use CamelCase for functions and methods.&lt;br /&gt;
* zxc_q - ΓÇ£qΓÇ¥ in the variable always represents ΓÇ£quantityΓÇ¥ or ΓÇ£number of ...ΓÇ¥.&lt;br /&gt;
* 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.&lt;br /&gt;
* zxc_req - ΓÇ£reqΓÇ¥ always means ΓÇ£requirementsΓÇ¥.&lt;br /&gt;
* 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_ΓÇ¥ -&amp;gt; ΓÇ£prf_some_variableΓÇ¥, ΓÇ£prf_SomeFunctionΓÇ¥.&lt;br /&gt;
&lt;br /&gt;
=== Internal scripts (Overridable) ===&lt;br /&gt;
{{Main|VoidExpanse/Internal_scripts|Internal scripts}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Global scripts (called in the world dynamically) ===&lt;br /&gt;
{{Main|VoidExpanse/Global_scripts|Global scripts}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Object scripts ===&lt;br /&gt;
{{Main|VoidExpanse/Object_scripts|Object scripts}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Events ===&lt;br /&gt;
[[VoidExpanse/events|List of Events]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== VoidExpanse Scripting API ==&lt;br /&gt;
&lt;br /&gt;
=== Library inclusion and scopes usage ===&lt;br /&gt;
Preprocessor directive &amp;lt;code&amp;gt;include(libname.js);&amp;lt;/code&amp;gt; includes a library script into the current JS instance. Library scripts can also include other libraries (no echo effect will appear).&lt;br /&gt;
&lt;br /&gt;
Allows modders to use functions and objects of these libraries in this particular script instance.&lt;br /&gt;
* Include directive must be the first lines in the script file (not necessarily, but preferably - to maintain order in scripts).&lt;br /&gt;
* All include directives must be before the first function declaration in the file.&lt;br /&gt;
&lt;br /&gt;
Preprocessor directive &amp;lt;code&amp;gt;using(scopename);&amp;lt;/code&amp;gt; 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.&lt;br /&gt;
&lt;br /&gt;
=== Scopes ===&lt;br /&gt;
Each scope contains a number of functions available from it.&lt;br /&gt;
&lt;br /&gt;
* [[VoidExpanse/scope-config]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-script]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-actions]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-server]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-generator]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-spawn]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-station]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-chat]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-console]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-storage]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-game]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-ship]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-visual]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-player]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-topic]] (available: only in topics)&lt;br /&gt;
* [[VoidExpanse/scope-topics]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-relations]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-npc]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-timer]] (available: global)&lt;br /&gt;
* [[VoidExpanse/scope-debug]] (available: global)&lt;br /&gt;
&lt;br /&gt;
== Device scripts ==&lt;br /&gt;
{{Main|VoidExpanse/Device_scripts|Device scripts}}&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
There are four possible functions for device script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Consumables scripting ==&lt;br /&gt;
{{Main|VoidExpanse/Consumable_scripting|Consumables scripting}}&lt;br /&gt;
Consumables can be programmed with standard xml-values, but, in order to implement something&lt;br /&gt;
special, one can use special techniques described in this article.&lt;/div&gt;</summary>
		<author><name>Tjmonk15</name></author>
	</entry>
	<entry>
		<id>https://wiki.atomictorch.com/index.php?title=VoidExpanse/Consumable_scripting&amp;diff=249</id>
		<title>VoidExpanse/Consumable scripting</title>
		<link rel="alternate" type="text/html" href="https://wiki.atomictorch.com/index.php?title=VoidExpanse/Consumable_scripting&amp;diff=249"/>
		<updated>2014-07-25T03:16:09Z</updated>

		<summary type="html">&lt;p&gt;Tjmonk15: Grammar, punctuation, phrasing edits.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Consumables Scripting ==&lt;br /&gt;
&lt;br /&gt;
In most cases the standard xml-structures are more than enough to implement consumable effects. However, if we need&lt;br /&gt;
to do something special, for example, restock ammo, self-destruct, teleport or kill all ships in front of the player, you will need scripts.&lt;br /&gt;
&lt;br /&gt;
There are no hard rules for scripting consumables, here are just a couple of tips.&lt;br /&gt;
For example, if we need to create a consumable that refills ammo in all of the players ballistic weapons.&lt;br /&gt;
First of all, we need to create a basic consumable xml, with an empty effects node.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	&amp;lt;effects&amp;gt;&lt;br /&gt;
		&amp;lt;!-- no effects here --&amp;gt;&lt;br /&gt;
	&amp;lt;/effects&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you create a new global script in folder /scripts/globals/, in which you hook some function to a special trigger:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function OnInit()&lt;br /&gt;
{&lt;br /&gt;
	actions.BindToTrigger(&amp;quot;onConsumableUsed&amp;quot;, &amp;quot;onBallisticAmmoConsumableUsed&amp;quot;,&lt;br /&gt;
		{id: &amp;quot;consumable_ballistic_ammo&amp;quot;});&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After that, every time a player uses a consumable with the xml-id &amp;quot;consumable_ballistic_ammo&amp;quot;, function &amp;quot;onBallisticAmmoConsumableUsed&amp;quot; will be called.&lt;br /&gt;
&lt;br /&gt;
Now, all that&#039;s left is to implement the actual ammo refill:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function onBallisticAmmoConsumableUsed( args )&lt;br /&gt;
{&lt;br /&gt;
	var ballisticWeapons = ship.GetWeaponsOfType( args.ship_id, 2 );&lt;br /&gt;
	if(ballisticWeapons == null) return;&lt;br /&gt;
	&lt;br /&gt;
	for(var i =0; i &amp;lt; ballisticWeapons.length; i++)&lt;br /&gt;
	{&lt;br /&gt;
		ship.RefillAmmoForWeapon( args.ship_id, ballisticWeapons[i] );&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That&#039;s all, now we have a consumable that refills ammo the of all ballistic weapons!&lt;/div&gt;</summary>
		<author><name>Tjmonk15</name></author>
	</entry>
</feed>