trusted-editors
115
edits
Please create an account or Login! Have fun!
(Add lax variable name rules description) |
(Update things from Architect's C2G reference) |
||
Line 75: | Line 75: | ||
If a variable name is invalid, CC2 will search the substrings of the variable name to find a variable name: | If a variable name is invalid, CC2 will search the substrings of the variable name to find a variable name: | ||
10 highspeed = ; Same as 10 speed = | 10 highspeed = ; Same as 10 speed = | ||
=== Variables === | |||
In most cases, the way C2G scripts interact with gameplay is by writing values to variables. | |||
C2G scrips have access to quite a few variables (see Reference), and some of them are for C2G scripters to use for custom data (reg1 through 4). | |||
All variables are signed 32-bit integers. | |||
=== Score === | === Score === | ||
Line 135: | Line 143: | ||
<nowiki><#> tleft =</nowiki> | <nowiki><#> tleft =</nowiki> | ||
Replace "<#>" with the desired time limit for the set. This will ignore any time limits set for individual levels. Time limits will be carried over from one level to the next, and restarting the level does not reset the time limit. [[Time bonus]]es and [[time penalty|time penalties]] can still be used. After the time limit reaches 0, or if a level is skipped, all future levels will be untimed. | Replace "<#>" with the desired time limit for the set. This will ignore any time limits set for individual levels. Time limits will be carried over from one level to the next, and restarting the level does not reset the time limit. [[Time bonus]]es and [[time penalty|time penalties]] can still be used. After the time limit reaches 0, or if a level is skipped, all future levels will be untimed. | ||
=== Conditional execution === | |||
By default, all of the lines in a C2G script are executed, with the only condition of not being invalid. "do" statements can allow for directives to be executed under conditions. | |||
To do this, the directive which is supposed to be conditioned should be prefixed with: | |||
<nowiki> <condition> do </nowiki> | |||
Replace <condition> with the expression which should be checked for being true. | |||
<nowiki>100000 score > do 13 tools =</nowiki> | |||
The above example will give the player a secret eye going into the next level if their overall score is greater than 100000. | |||
=== Goto === | |||
By default, C2G files are read linearly from top to bottom, but "goto" directives can allow level skipping or looping. | |||
In order to do this, the end point of the jump must be given a label starting with a pound (#) character. For example: | |||
<nowiki>#loop | |||
map "DejaVu.c2m" | |||
map "StuckInALoop.c2m"</nowiki> | |||
In the example above, the levels DejaVu.c2m and StuckInALoop.c2m are given the label "loop". | |||
<nowiki>map "NormalProgression.c2m" | |||
#loop | |||
map "DejaVu.c2m" | |||
map "StuckInALoop.c2m" | |||
goto #loop</nowiki> | |||
In the example above, completing StuckInALoop.c2m will always take you back by one level to DejaVu.c2m. | |||
"goto" directives can be combined with "do" directives, for example: | |||
<nowiki>map ManyKeys.c2m | |||
keys 67306285 != do goto #normalPath | |||
script | |||
"you have found" | |||
"the secret key" | |||
"combination!" | |||
"you should rest" | |||
"a bit" | |||
map RelaxingBeach.c2m | |||
#normalPath | |||
map ManyTools.c2m</nowiki> | |||
In the above example, if after playing ManyKeys.c2m, the last exited player has exactly 1 red, 2 blue, 3 yelow and 4 green keys, they see the text message and play RelaxingBeach.c2m. After that, the secret and normal paths join and in both cases ManyTools.c2m is played next. | |||
=== Entry choices === | |||
If a level has several [[Player character]]s, C2G scripting can be used to set the player which will appear based on conditions. | |||
Players are numbered in reading order, starting at 1; there does not appear to be any limit. In order to use the feature, before calling the "map" of the level containing the players, the "enter" variable must be set, for example: | |||
<nowiki><#> enter =</nowiki> | |||
Replace <#> with an expression (which must evaluate to a number) or a number. For example: | |||
<nowiki>1 enter = | |||
0 rand > do 2 enter = | |||
map UltimatePain.c2m</nowiki> | |||
In the above example, with about 50% chance, the second players will appear in the level UltimatePain.c2m instead of the first one. | |||
CC2 crashes if "enter" is set to a value which does not lead to a player. | |||
=== Exit choices === | === Exit choices === | ||
If a level has several [[exit]]s, C2G scripting can be used to send the player to different levels depending on what exit is entered. | If a level has several [[exit]]s, C2G scripting can be used to send the player to different levels depending on what exit is entered. | ||
Exits are numbered in reading order, starting at 1; there does not appear to be any limit. In order to use the feature, after calling the "map" of the level containing the exits, "do" and "goto" need to be combined in a similar manner: | |||
Exits are numbered in reading order, starting at 1; there does not appear to be any limit. In order to use the feature, after calling the "map" of the level containing the exits, a | |||
<nowiki> <#> exit == do goto #label</nowiki> | <nowiki> <#> exit == do goto #label</nowiki> | ||
Replace <#> with the exit number, and #label with the label name (including the #). For example: | Replace <#> with the exit number, and #label with the label name (including the #). For example: | ||
Line 174: | Line 231: | ||
If there are several players in the level, the gender of the last one to finish the level will be the one used by the C2G script. If an invalid label is called, or no line is specified for a specific gender, the game will continue to work through the C2G file as it would normally. | If there are several players in the level, the gender of the last one to finish the level will be the one used by the C2G script. If an invalid label is called, or no line is specified for a specific gender, the game will continue to work through the C2G file as it would normally. | ||
=== Fake level numbers === | === Fake level numbers === | ||
Line 255: | Line 303: | ||
<pre>2 exit == do goto #secret</pre> | <pre>2 exit == do goto #secret</pre> | ||
|- | |- | ||
| ==<br /><=<br />>=<br />!=<br /><<br />> | | ==<br /><=<br />>=<br />!=<br /><<br />><br/>&&<br/>||<br/>+<br/>-<br/>*<br/>/<br/>%<br/>&<br/>|<br/>^ | ||
| binary operator | | binary operator | ||
| <pre><expressions...> <operator></pre> | | <pre><expressions...> <operator></pre> | ||
Line 283: | Line 331: | ||
| variable | | variable | ||
| <pre>enter</pre> | | <pre>enter</pre> | ||
| | | Contains the used playable in the next level (see above). | ||
|- | |- | ||
| SCORE | | SCORE | ||
Line 368: | Line 416: | ||
reg3 | reg3 | ||
reg4</pre> | reg4</pre> | ||
| | | Variables intended for use for complex operations in scripts. | ||
|- | |- | ||
| FLAGS | | FLAGS | ||
Line 383: | Line 431: | ||
| directive | | directive | ||
| <pre>chain "<filename>"</pre> | | <pre>chain "<filename>"</pre> | ||
| | | Stops the current script and starts the one specified in <filename>. | ||
|- | |- | ||
| LINE | | LINE | ||
| variable | | variable | ||
| <pre>line</pre> | | <pre>line</pre> | ||
| | | The currently processed line in the current C2G script. | ||
|- | |- | ||
| CHDIR | | CHDIR | ||
Line 448: | Line 496: | ||
| directive | | directive | ||
| <pre>art "..."</pre> | | <pre>art "..."</pre> | ||
| | | Was supposed to replace a part of the tileset with custom art. Was removed due to being impossible to implement. | ||
|- | |- | ||
| WAV | | WAV | ||
| directive | | directive | ||
| <pre>wav "..."</pre> | | <pre>wav "..."</pre> | ||
| | | May have been inteded to load a custom set of sound effects from a path. | ||
|- | |- | ||
| RAND | | RAND | ||
| pseudo-variable | | pseudo-variable | ||
| <pre>rand</pre> | | <pre>rand</pre> | ||
| When read, generates a pseudo-random integer. | | When read, generates a pseudo-random integer. (since all variables are signed 32-bit values, the minimal and maximum values are −2,147,483,648 and 2,147,483,647, respectively) | ||
|- | |- | ||
| SPEED | | SPEED | ||
Line 473: | Line 521: | ||
| unknown | | unknown | ||
| | | | ||
| Appears to be | | Appears to be used. May have been used to debug [[swivel]] behavior. | ||
|- | |- | ||
| MAIN | | MAIN |