C2G: Difference between revisions
→Reference: remove duplicate entry from table
No edit summary |
(→Reference: remove duplicate entry from table) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 3: | Line 3: | ||
While individual levels are stored in [[C2M]] files, C2G files arrange these levels in [[levelset]]s. C2G files can also be used to specify music tracks, text between levels, and several forms of advanced scripting. | While individual levels are stored in [[C2M]] files, C2G files arrange these levels in [[levelset]]s. C2G files can also be used to specify music tracks, text between levels, and several forms of advanced scripting. | ||
The official set does not use any advanced C2G features, nor did [[Chuck Sommerville]] provide any documentation; there | The official set does not use any advanced C2G features, nor did [[Chuck Sommerville]] provide any documentation; there may be features still undiscovered by the community. | ||
== Basic usage == | == Basic usage == | ||
Line 135: | Line 135: | ||
2564 tools = | 2564 tools = | ||
Note that tool codes | Note that tool codes between 17 and 127 will be reduced to a value <= 16. Codes from 128 to 257 produce [[negative items | strange results]]. Key counts > 9 will be reduced to 9. | ||
=== Timed levelset === | === Timed levelset === | ||
Line 248: | Line 248: | ||
In the example above, Normal.c2m will be level 9. | In the example above, Normal.c2m will be level 9. | ||
No matter how your level numbering is set up, completing a level will always briefly display the current level as being | No matter how your level numbering is set up, completing a level will always briefly display the current level as being its previous value + 1. This is unavoidable. | ||
=== Speed === | === Speed === | ||
Line 276: | Line 276: | ||
=== Chaining === | === Chaining === | ||
Scripts can be "chained" using the chain directive. This can be useful for compartmentalizing long scripts associated with particular levels. | Scripts can be "chained" using the chain directive; immediately stopping the parsing of the current script and starting again on the first line of the chained script. This can be useful for compartmentalizing long scripts associated with particular levels. | ||
<nowiki>chain "anotherscript.c2g"</nowiki> | <nowiki>chain "anotherscript.c2g"</nowiki> | ||
Line 282: | Line 282: | ||
chain "scriptinanotherdirectory.c2g"</nowiki> | chain "scriptinanotherdirectory.c2g"</nowiki> | ||
Note that if the first c2g file CC2 reads chains to another script but does not provide a map itself, CC2 will say the levelset is invalid. This is because it specifically checks the first c2g it reads for the use of "map" followed by a valid map. To avoid this, put a valid map ''after'' calling the chain, such that it will never be accessed since the parser will be chained away from the script before reaching it. | Note that if the first c2g file CC2 reads chains to another script but does not provide a map itself, CC2 will say the levelset is invalid. This is because it specifically checks the first c2g it reads for the use of "map" followed by a valid map. To avoid this, put a valid map ''after'' calling the chain, such that it will never be accessed since the parser will be chained away from the script before reaching it. | ||
=== Level flags === | |||
Variables reg1 to reg4 can be used to store arbitrary flags, will be stored between chained scripts, and will be included in the player's save data. Here, a "switch palace" level includes two exits, the second of which sets the lowest bit in reg4 to 1, which the script then detects to swap out a later level for an alternate version: | |||
<nowiki>map "SwitchPalace.c2m" | |||
1 exit == do goto #afterpalace | |||
script | |||
"You touched the switch!" | |||
"This will swap some" | |||
"walls and floors in" | |||
"a future level" | |||
1 reg4 | reg4 = | |||
#afterpalace | |||
map "BoringLevel.c2m" | |||
map "NormalLevel.c2m" | |||
map "GreatLevel.c2m" | |||
1 reg4 && do goto #switchon | |||
#switchoff | |||
map "AwesomeLevel.c2m" | |||
goto #afterawesome | |||
#switchon | |||
map "AwesomeLevelAlt.c2m" | |||
#afterawesome | |||
map "OkayLevel.c2m"</nowiki> | |||
Unused bits of the "flags" variable itself are also available, but flipping them is unadvised, as, theoretically, future updates to CC2 could add new purposes to unused flags at any moment. | |||
== Comments box == | == Comments box == | ||
Certain C2G scripts, notably ktools and speed can be placed inside a [[C2M|specific level file]]'s comments field, and will apply to the level itself. To do this, the comments field must contain the following line: | Certain C2G scripts, notably ktools and speed can be placed inside a [[C2M|specific level file]]'s comments field, and will apply to the level itself. To do this, the comments field must contain the following line: | ||
<nowiki>[COM]</nowiki> | <nowiki>[COM]</nowiki> | ||
followed, on subsequent lines, by the C2G parameters. | followed, on subsequent lines, by the C2G parameters. For example, this will cause all players to start the level with fire boots and flippers. | ||
<nowiki> | |||
[COM] | |||
flags ktools | flags = 1027 tools =</nowiki> | |||
== Reference == | == Reference == | ||
Line 457: | Line 492: | ||
| | | | ||
| Appears to be unused. | | Appears to be unused. | ||
|- | |- | ||
| REPLAY | | REPLAY |