Scripting - SamClassicPatch/SuperProject GitHub Wiki
A guide to scripting within Classics Patch using its "Scripting Engine" plugin.
- Squirrel scripting language: http://squirrel-lang.org/
- Official documentation: http://squirrel-lang.org/squirreldoc/
- Valve Development Community documentation: https://developer.valvesoftware.com/wiki/Squirrel
Right now, the only scripting language Classics Patch supports is Squirrel 3.2.
Squirrel is a scripting language with C-like syntax designed for games.
It can be used for implementing new mechanics (such as new gamemodes) without having to code your own plugins for the patch.
Scripts are much more efficient and versatile than the engine's shell language.
Language | Syntax | Object-oriented | Dynamic types | Integer type | Float type | Boolean type | String type | Arrays | Type conversion | Global variables | Local variables | Control flow statements | Loop statements | Classes | Functions | Code nesting |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SE1 shell | C-like | No | No | Signed 32 bits | Single precision | Integer type | Yes | Limited | Explicit | Yes | No |
if , else , else if
|
N/A | N/A | Execution | Standard include "path" command; custom IncludeScript(<path>) function |
Squirrel | C-like | Yes | Yes | Signed 64 bits | Single precision | Yes | Yes | Yes | Implicit, explicit | Yes | Yes |
if , else , else if , switch-case
|
while , do-while , for , foreach
|
Yes | Definition, execution, lambdas | Custom IncludeScript(<path>) function |
Scripting Engine extension implements specific libraries to allow interactions with the game and the engine via scripts.
Library | Squirrel table | Purpose |
---|---|---|
Entities | Entities |
[UNFINISHED] |
File system | FileSystem |
[UNFINISHED] |
Input | Input |
Input polling from keyboard, mouse and joysticks. |
Messages | Message |
Message boxes and other information output. |
Network | Network |
[UNFINISHED] |
Shell | Shell |
Interactions with the engine shell. |
Timer | Timer |
Reading current game/frame time. |
Utilities | Utils |
Helper classes and functions, not strictly under the library namespace (global). |
World | World |
[UNFINISHED] |