| Revision as of 15:47, 21 February 2009 Gcamp (Talk | contribs) ← Previous diff |
Revision as of 23:01, 21 February 2009 Gcamp (Talk | contribs) Scripting Next diff → |
||
| Line 12: | Line 12: | ||
| : [[Server Side Scripts]] - Scripts used to alter the way the server plays the game | : [[Server Side Scripts]] - Scripts used to alter the way the server plays the game | ||
| : [[Weapon Scripts]] - Scripts used to create fancy weapons | : [[Weapon Scripts]] - Scripts used to create fancy weapons | ||
| + | |||
| + | ==Tables== | ||
| + | |||
| + | LUA makes heavy use of tables to store structured data. Scorched3D represents most of its complex information as tables. For example the position and velocity vectors are represented as tables containing three entries (x, y & z). You can access these entries by using the fullstop, e.g. table.x | ||
| + | |||
| + | See the [http://www.lua.org/manual/5.1 LUA Documentation] for a more detailed explanation of table operations. | ||
| + | |||
| + | See [[Scorched3D LUA Tables]] for list of supported Scorched3D tables. | ||
| + | |||
| + | ==Numbers== | ||
| + | |||
| + | Its probably worth noting that internaly Scorched3D uses fixed point maths. All numbers used by the engine are stored as fixed point, including those used by the LUA library. This ensures that all maths operations (and so the simulation) remains consistent accross different architectures. | ||
| + | |||
| + | But don't worry this is completely hidden from you at all times, other than a slightly reduced maths accuracy it shouldn't be noticable. The fixed point numbers used currently support up to four decimal places (.0001) and numbers up to two hundred thousand (200000). | ||
| ==Security== | ==Security== | ||
| LUA is a fully functioning programming (scripting) language ([http://www.lua.org/manual/5.1 LUA Documentation]). However LUA scripts run within a virtual machine that only allows it to perform specified operations. When LUA was added to Scorched3D any operation that was deemed to be unsecure was removed from the language. Amongst these included accessing any operating system functions and file reading/writing. | LUA is a fully functioning programming (scripting) language ([http://www.lua.org/manual/5.1 LUA Documentation]). However LUA scripts run within a virtual machine that only allows it to perform specified operations. When LUA was added to Scorched3D any operation that was deemed to be unsecure was removed from the language. Amongst these included accessing any operating system functions and file reading/writing. | ||
Contents |
Scorched 3D supports the use of scripts to both enhance the engine and to create new and funky weapons. Scripting support was introduced in Scorched3D version 42.
Scripts are written in the LUA scripting language. Scorched3D adds some new functions and structures to LUA so the script can interact with the scorched engine. For example these functions allow you to fire a weapon or send a message to other players.
Scripting is useful when you want to perform actions based on complex decisions, or simply when an alternative is not available via the XML configuration files. For example you may want to find all the players in a given team and give them some money, or kill all players below a certain amount of health. Scripting makes all of this possible.
LUA makes heavy use of tables to store structured data. Scorched3D represents most of its complex information as tables. For example the position and velocity vectors are represented as tables containing three entries (x, y & z). You can access these entries by using the fullstop, e.g. table.x
See the LUA Documentation for a more detailed explanation of table operations.
See Scorched3D LUA Tables for list of supported Scorched3D tables.
Its probably worth noting that internaly Scorched3D uses fixed point maths. All numbers used by the engine are stored as fixed point, including those used by the LUA library. This ensures that all maths operations (and so the simulation) remains consistent accross different architectures.
But don't worry this is completely hidden from you at all times, other than a slightly reduced maths accuracy it shouldn't be noticable. The fixed point numbers used currently support up to four decimal places (.0001) and numbers up to two hundred thousand (200000).
LUA is a fully functioning programming (scripting) language (LUA Documentation). However LUA scripts run within a virtual machine that only allows it to perform specified operations. When LUA was added to Scorched3D any operation that was deemed to be unsecure was removed from the language. Amongst these included accessing any operating system functions and file reading/writing.