C2G: Difference between revisions

5,264 bytes added ,  9 June 2020
Provide more details on c2g script keywords and tokens
mNo edit summary
(Provide more details on c2g script keywords and tokens)
Line 227: Line 227:
followed, on subsequent lines, by the C2G parameters.
followed, on subsequent lines, by the C2G parameters.


== Complete set of keywords ==
== Reference ==
On September 19th, 2019, [[Joshua Bone]] posted a complete list of keywords that can or could be used in C2G scripting, including numbers and comparison operators. The function of some keywords in here is unknown, and some formerly did something but are now just gibberish to the engine (NO_L_DOORS for example).
The following is a list of all keywords and tokens recognized by the c2g parser. The function of some keywords in here is unknown, and some formerly did something but are now just gibberish to the engine (NO_L_DOORS for example).  Note that keywords are case-insensitive.
  <nowiki>MUSIC
 
GOTO
{| class="wikitable"
DO
! Token
==
! Type
<=
! Syntax
>=
! Description
!=
|-
=
| MUSIC
<
| directive
>
| <pre>music "&lt;filename&gt;"</pre>
LEVEL
| Specifies a music file to play for the next script element.
GENDER
|-
EXIT
| GOTO
ENTER
| directive
SCORE
| <pre>goto #&lt;label&gt;</pre>
BONUS
| Move script execution to the specified #label
MENU
|-
CHIPS
| DO
START
| directive
MALE
| <pre>&lt;conditional&gt; do ...</pre>
FEMALE
| If the preceding condition is true, do the following command.  Example:
MAP
  <pre>2 exit == do goto #secret</pre>
SCRIPT
|-
"
| ==<br />&lt;=<br />&gt;=<br />!=<br />&lt;<br />&gt;
#
| binary operator
0
| <pre>&lt;expressions...&gt; &lt;operator&gt;</pre>
1
| Pop two values from the preceding expressions and compare them with the specified operator, then push the result.  The operators have the same meanings as in C.
2
|-
3
| =
4
| assignment
5
| <pre>&lt;expression&gt; &lt;variable&gt; =</pre>
6
| Assign the specified value from the preceding expression to &lt;variable&gt;.
7
|-
8
| LEVEL
9
| variable
;
| <pre>level</pre>
//
| Contains the current level number.  The first level is 1.
END
|-
RESULT
| GENDER
REG1
| variable
REG2
| <pre>gender</pre>
REG3
| Contains the player's current gender (male or female).
REG4
|-
FLAGS
| EXIT
EDIT
| variable
CHAIN
| <pre>exit</pre>
LINE
| Contains the most recently used exit (see above).
CHDIR
|-
SCREEN
| ENTER
*
| variable
/
| <pre>enter</pre>
+
| Use is currently unknown.
-
|-
&&
| SCORE
&
| variable
||
| <pre>score</pre>
| Contains the current score for the levelset.
|-
| BONUS
| unknown
|
|
%
| Appears to be unused.
^
|-
REPLAY
| MENU
CONTINUE
| variable
SILENT
| <pre>menu</pre>
KTIME
| Use is currently unknown.
KTOOLS
|-
TLEFT
| CHIPS
TOOLS
| unknown
KEYS
|
ART
| Appears to be unused.
WAV
|-
RAND
| START
SPEED
| unknown
NO_BONUS
|
NO_L_DOORS
| Appears to be unused.
MAIN
|-
GAME
| MALE
DLC</nowiki>
| constant
| <pre>male</pre>
| Value: 0x16<br />"male" constant for gender variable.
|-
| FEMALE
| constant
| <pre>female</pre>
| Value: 0x56<br />"female" constant for gender variable.
|-
| MAP
| directive
| <pre>map "&lt;filename&gt;"</pre>
| Specifies the map file to use for the next level.
|-
| SCRIPT
| directive
| <pre>script</pre>
| Begins "script" mode for displaying text (see above).
|-
| "
| string
| <pre>"..."
"... %&lt;format&gt; ..." &lt;value&gt;</pre>
| Strings begin and end with a double-quote (").  There does not appear to be any capability for escaping characters.  However, formatting can be applied with printf-style format strings (see above).
|-
| #
| label
| <pre>#&lt;name&gt;</pre>
| Labels can be jumped to with the "goto" directive.  There appears to be some interaction with the **end** directive, but this is untested.
|-
| 0..9
| integer
| <pre>1234</pre>
| Integer literal.  Can only be specified in decimal (digits 0-9).
|-
| ;<br/>//
| comment
| <pre>; comment text
// comment text</pre>
| Comments are ignored until the end of the current line.
|-
| END
| directive
| <pre>end</pre>
| There appears to be some interaction with labels, but this is untested.
|-
| RESULT
| variable
| <pre>result</pre>
| Use is currently unknown.  Possibly contains the result of arithmetic expressions?
|-
| REG1<br />REG2<br />REG3<br />REG4
| variable
| <pre>reg1
reg2
reg3
reg4</pre>
| Use is currently unknown.  Possibly used as scratch registers for more complex expression evaluation?
|-
| FLAGS
| variable
| <pre>flags</pre>
| Specifies flags (bitwise OR'ed) for the current gameplay.  See sections above for details.
|-
| EDIT
| directive
| <pre>edit</pre>
| Start the built-in level editor.
|-
| CHAIN
| directive
| <pre>chain "&lt;filename&gt;"</pre>
| Use is currently unknown.
|-
| LINE
| variable
| <pre>line</pre>
| Use is currently unknown.
|-
| CHDIR
| directive
| <pre>chdir "&lt;path&gt;"</pre>
| Change the game's current working directory to &lt;path&gt;.
|-
| SCREEN
| unknown
|
| 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
| constant
| <pre>replay</pre>
| Value: 0x2<br />When set in flags, automatically replay recorded solutions.
|-
| CONTINUE
| constant
| <pre>continue</pre>
| Value: 0x1<br />When set in flags, automatically continue to the next level.
|-
| SILENT
| constant
| <pre>silent</pre>
| Value: 0x4<br />When set in flags, ?
|-
| KTIME
| constant
| <pre>ktime</pre>
| Value: 0x20<br />When set in flags, keep the time limit across levels.
|-
| KTOOLS
| constant
| <pre>ktools</pre>
| Value: 0x10<br />When set in flags, keep collected tools (items and keys) across levels.
|-
| TLEFT
| variable
| <pre>tleft</pre>
| Contains the global time limit when ktime is set in flags.
|-
| TOOLS
| variable
| <pre>tools</pre>
| Contains the current tools inventory (see above).
|-
| KEYS
| variable
| <pre>keys</pre>
| Contains the current keys inventory (see above).
|-
| ART
| directive
| <pre>art "..."</pre>
| Use is currently unknown.
|-
| WAV
| directive
| <pre>wav "..."</pre>
| Use is currently unknown.
|-
| RAND
| pseudo-variable
| <pre>rand</pre>
| When read, generates a pseudo-random integer.
|-
| SPEED
| variable
| <pre>speed</pre>
| Contains the current gameplay speed.  1 = 100% (normal speed).
|-
| NO_BONUS
| constant
| <pre>no_bonus</pre>
| Value: 0x40<br />When set in flags, disables bonus flag pickup (see above for details).
|-
| NO_L_DOORS
| unknown
|
| Appears to be unused.
|-
| MAIN
| directive
| <pre>main</pre>
| Use is currently unknown.  Appears to jump to "playcc2.c2g" from the current levelset or script.
|-
| GAME
| directive
| <pre>game "&lt;name&gt;"</pre>
| Sets the name of the current levelset to &lt;name&gt;
|-
| DLC
| directive
| <pre>dlc "..."</pre>
| Use is currently unknown.
|}


[[Category:File formats]]
[[Category:File formats]]
trusted-editors
10

edits