Scorched3D supports a huge amount of functionality "out of the box". However, sometimes you may wish to perform some actions that are specific to your server, and are so specific they will never be in an actual release of Scorched3D. Perhaps you wish to reward players with a certain clan tag, or award more points for different objectives, or even implement a betting system.
Scorched3D allows the server to be enhanced through the use of server side scripts written in the LUA scripting language. These scripts are plugged into the engine and are called when the engine makes certain decisions or performs certain operations.
See Scorched3D scripting home for an introduction to scripting on Scorched3D.
Server 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.
As previously mentioned Scorched3D can be configured to call a server script (or many scripts) when a specific action occurs. The scripts are hooked into the server by registering them with a hook name. The server has a set of pre-defined hook names that it already knows about. When the server performs certain actions it also executes the scripts registered agains the action's hook name.
The server hooks need to be placed into a directory called serverhooks in your scorched3d user settings directory. This directory is usualy in :
c:\documents and settings\<user name>\.scorched\serverhooks - for windows ~/.scorched/serverhooks - for unix
The hooks are configured via XML files in this directory (these files must have the .xml file extension).
Here is an example hook file:
<hooks> <hook> <filename>testscript.lua</filename> <hook> <hookname>server_channeltext</hookname> <entrypoint>server_channeltextmethod</entrypoint> </hook> <hook> <hookname>server_newgame</hookname> <entrypoint>server_newgamemethod</entrypoint> </hook> </hook> </hooks>
This file registers two hooks, both with the same script file (a hook file can register any number of hooks):