I am far from being an expert in the realm of scripting, but simple scripts are not too difficult to
understand.
I will try to keep it very simple.
Let's say you want to open a door in a particular fashion. The normal way would be to apply an action special 11: Open Door to:
In all of those cases the player causes a single event, namely to open a door.
But how does one apply a script to do the same thing?
The structure of a script is thus:
#include "zcommon.acs" script 1 (void) { // do some stuff }
So, what does that mean? Let's take a look at each line.
#include "zcommon.acs" is very important. Without it the compiler will not know what to do.
Actually, zcommon.acs is a short version of including 3 separate definitions:
From time to time, check out https://github.com/rheit/acc/ for the latest versions.
If one wanted to, one could write this also as:
#include "zwvars.acs" #include "zdefs.acs" #include "zspecial.acs" script 1 (void) { // do some stuff }
script 1 (void) tells the compiler the script is of type (void). There are other types. GZDoom now allows to specify a script by name instead of by a number. For example:
script"Open a Door" instead of script 1"
(void) is used when some event is triggered in the map.Each body of the script must be within curly brackets:
{ at the start of the script
} at the end of the script
// can be used to type some comment to remind you what that line is about in case you come back to it later
Therefore, to use a script to open a door, as in the above examples, the script would look like this:
#include "zcommon.acs" script 1 (void) { // 11: Door_Open (tag, speed, lighttag); // Open a Door after the Demon is killed Door_Open (100, 10, 0); // 100 is tag of the door sector // 10 is speed of the door opening up // keep lighttag at 0 }
Once you finish the script text, it must be compiled. Press the compile button. If an error creeps in, then the compiler will show a message at the bottom of the window.
Here it is in action when killing a monster:
Now, rather then attaching the action special 11: Open_Door as in the top examples, the
action special
80: Script_Execute
is attached. Do not forget to specify the script number.
With ACS being a derivative of the C language, many possibilties open up.