Scorched3D supports configurable weapons via its XML accessory definition files, see current scorched3d weapons. The XML definitions allow you to make an almost limitless number of complex weapons, and in most cases this is the easiest way to create new weapons.
In some cases the XML accessory definition files don't allow you to create the weapons you want, perhaps the weapons are very complex or the XML syntax doesn't exist. For these occasions you can Weapon Scripts.
Instead of XML Weapon scripts use the LUA scripting language to define Scorched3D weapons. See Scorched3D scripting home for an introduction to scripting on Scorched3D.
Weapon scripts are written as normal text files containing LUA code. See LUA Documentation for documentation on the LUA scripting language.
All of the standard libraries are documented in the LUA Documentation, with the exception of the Scorched3D functions. The Scorched3D functions allow scripts to interact with and manipulate the Scorched3D engine.
In fact the configuration for the Weapon Scripts is in the existing XML file (accessories.xml), but this is purely used to tell Scorched where to find the script and when to use it. Weapon scripts are defined in new type of accessoryaction called WeaponScript. This WeaponScript is just a 'normal' accessoryaction and can be used interchangably with other accessoryactions in the accessories.xml.
Here is an example WeaponScript accessory action:
<accessoryaction type="WeaponScript"> <filename>data/lua/accessories/test.lua</filename> <entrypoint>runWeapon</entrypoint> <variable> <name>testvar1</name> <value>10</value> </variable> </accessoryaction>
The above accessoryaction has two mandatory parts, the filename and the entrypoint:
Here is an example use of a WeaponScript:
<accessory> <name>Test Script</name> <bundlesize>2</bundlesize> <cost>10</cost> <accessoryaction type="WeaponScript"> <filename>data/lua/accessories/test.lua</filename> <entrypoint>runWeapon</entrypoint> </accessoryaction> </accessory>
The above accessory creates a weapon called 'Test Script'. When the tank fires this weapon the runWeapon function in the data/lua/accessories/test.lua script will be executed.
Obviously this is a very simple example and as stated earlier you can use WeaponScripts anywhere that you can use an accessoryaction.