C2G: Difference between revisions

21 bytes removed ,  15 January
→‎Reference: remove duplicate entry from table
No edit summary
(→‎Reference: remove duplicate entry from table)
 
(6 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 are several features that have not yet been discovered by the community.
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 > 16 will be reduced to a value <= 16, and key counts > 9 will be reduced to 9. These limits do not apply when either inventory is carried over from the previous level.
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 278: Line 278:
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.
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>
  <nowiki>chdir "anotherdirectory\"
  <nowiki>chdir "anotherdirectory\"
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.


=== Registers ===
=== 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 the next level for an alternate version:
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"
  <nowiki>map "SwitchPalace.c2m"
1 exit == do goto #afterpalace
1 exit == do goto #afterpalace
Line 311: Line 312:


map "OkayLevel.c2m"</nowiki>
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 486: Line 492:
|
|
| Appears to be unused.
| Appears to be unused.
|-
| *<br />/<br />+<br />-<br />&amp;&amp;<br />&amp;<br />&#124;&#124;<br />&#124;<br />%<br />^
| binary operator
| <pre>&lt;expressions...&gt; &lt;operator&gt;</pre>
| Pop two values from the preceding expressions and evaluate them with the specified operator, then push the result.  The operators have the same meanings as in C.
|-
|-
| REPLAY
| REPLAY
Anonymous user