TrustedUser
2,147
edits
m |
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=") |
||
Line 9: | Line 9: | ||
Normal action commands are specified by the command name followed by parentheses which contain the arguments, separated by commas. A semicolon is placed after the parentheses. The parentheses are required even if there are no arguments. The arguments given must have the correct prefix for that type of argument as explained later in this document (this is to make sure the programmer does not use a [[AGIWiki/Variable|variable]], for example, when they think they are using a [[AGIWiki/Flag|flag]]). | Normal action commands are specified by the command name followed by parentheses which contain the arguments, separated by commas. A semicolon is placed after the parentheses. The parentheses are required even if there are no arguments. The arguments given must have the correct prefix for that type of argument as explained later in this document (this is to make sure the programmer does not use a [[AGIWiki/Variable|variable]], for example, when they think they are using a [[AGIWiki/Flag|flag]]). | ||
< | <syntaxhighlight lang="cpp"> | ||
assign.v(v50,0); | assign.v(v50,0); | ||
Line 17: | Line 17: | ||
Multiple commands may be placed on the one line: | Multiple commands may be placed on the one line: | ||
< | <syntaxhighlight lang="cpp"> | ||
reset(f6); reset(f7); | reset(f6); reset(f7); | ||
</source> | </source> | ||
Line 23: | Line 23: | ||
Substitutions for the following action commands are available: | Substitutions for the following action commands are available: | ||
< | <syntaxhighlight lang="cpp"> | ||
increment(v30); v30++; | increment(v30); v30++; | ||
decrement(v30); v30--; | decrement(v30); v30--; | ||
Line 46: | Line 46: | ||
An if structure looks like this: | An if structure looks like this: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (test commands) { | if (test commands) { | ||
action commands | action commands | ||
Line 54: | Line 54: | ||
or like this | or like this | ||
< | <syntaxhighlight lang="cpp"> | ||
if (test commands) { | if (test commands) { | ||
action commands | action commands | ||
Line 65: | Line 65: | ||
Carriage returns are not necessary: | Carriage returns are not necessary: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (test commands) { action Commands } else { more action commands } | if (test commands) { action Commands } else { more action commands } | ||
</source> | </source> | ||
Line 72: | Line 72: | ||
Test commands are coded like action commands except there is no semicolon. They are separated by <code>&&</code> or <code>||</code> for AND and OR, respectively: | Test commands are coded like action commands except there is no semicolon. They are separated by <code>&&</code> or <code>||</code> for AND and OR, respectively: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (isset(f5) && | if (isset(f5) && | ||
greatern(v5,6)) { ...... | greatern(v5,6)) { ...... | ||
Line 79: | Line 79: | ||
Again, carriage returns are not necessary within the if statement: | Again, carriage returns are not necessary within the if statement: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (lessn(v5,6) && (greatern(v5,2)) { ....... | if (lessn(v5,6) && (greatern(v5,2)) { ....... | ||
Line 88: | Line 88: | ||
A ! placed in front of a command signifies a NOT. | A ! placed in front of a command signifies a NOT. | ||
< | <syntaxhighlight lang="cpp"> | ||
if (!isset(f7)) { | if (!isset(f7)) { | ||
...... | ...... | ||
Line 95: | Line 95: | ||
Boolean expressions are not necessarily simplified so they must follow the rules set down by the file format. If test commands are to be ORred together, they must be placed in brackets. | Boolean expressions are not necessarily simplified so they must follow the rules set down by the file format. If test commands are to be ORred together, they must be placed in brackets. | ||
< | <syntaxhighlight lang="cpp"> | ||
if ((isset(f1) || isset(f2)) { | if ((isset(f1) || isset(f2)) { | ||
...... | ...... | ||
Line 109: | Line 109: | ||
Substitutions for the following test commands are available: | Substitutions for the following test commands are available: | ||
< | <syntaxhighlight lang="cpp"> | ||
equaln(v30,4) v30 == 4 | equaln(v30,4) v30 == 4 | ||
equalv(v30,v32) v30 == v32 | equalv(v30,v32) v30 == v32 | ||
Line 126: | Line 126: | ||
Also, flags can be tested for by just using the name of the flag: | Also, flags can be tested for by just using the name of the flag: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (f6) { ..... | if (f6) { ..... | ||
Line 134: | Line 134: | ||
which is equivalent to: | which is equivalent to: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (isset(f6)) { ..... | if (isset(f6)) { ..... | ||
Line 192: | Line 192: | ||
Compilers can enforce type checking, so that the programmer must use the correct prefix for an argument so that they know they are using the right type. Decoders should display arguments with the right type. | Compilers can enforce type checking, so that the programmer must use the correct prefix for an argument so that they know they are using the right type. Decoders should display arguments with the right type. | ||
< | <syntaxhighlight lang="cpp"> | ||
move.obj(o4, 80, 120, 2, f66); | move.obj(o4, 80, 120, 2, f66); | ||
Line 202: | Line 202: | ||
Messages and inventory items may be given in either numerical or text format: | Messages and inventory items may be given in either numerical or text format: | ||
< | <syntaxhighlight lang="cpp"> | ||
print("He's not here."); | print("He's not here."); | ||
Line 214: | Line 214: | ||
Messages can also be split over multiple lines: | Messages can also be split over multiple lines: | ||
< | <syntaxhighlight lang="cpp"> | ||
print("This message is split " | print("This message is split " | ||
"over multiple lines."); | "over multiple lines."); | ||
Line 221: | Line 221: | ||
Quote marks must be used around messages and inventory item names. This is important because some messages or inventory item names may contain parentheses or commas, which could confuse the compiler. This is also the case for the said command which will be described shortly. | Quote marks must be used around messages and inventory item names. This is important because some messages or inventory item names may contain parentheses or commas, which could confuse the compiler. This is also the case for the said command which will be described shortly. | ||
< | <syntaxhighlight lang="cpp"> | ||
if (has("Buckazoid(s)")) { ..... // no ambiguity here about where | if (has("Buckazoid(s)")) { ..... // no ambiguity here about where | ||
// the argument ends | // the argument ends | ||
Line 230: | Line 230: | ||
The said test command uses different parameters to all the other commands. Where as the others use 8 bit arguments (0-255), said takes 16 bit arguments (0-65535). Also, the number of arguments in a said command can vary. The numbers given in the arguments are the word group numbers from the WORDS.TOK file. | The said test command uses different parameters to all the other commands. Where as the others use 8 bit arguments (0-255), said takes 16 bit arguments (0-65535). Also, the number of arguments in a said command can vary. The numbers given in the arguments are the word group numbers from the WORDS.TOK file. | ||
< | <syntaxhighlight lang="cpp"> | ||
if (said(4, 80)) { ..... | if (said(4, 80)) { ..... | ||
</source> | </source> | ||
Line 236: | Line 236: | ||
Words can also be given in place of the numbers: | Words can also be given in place of the numbers: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (said("look")) { ..... | if (said("look")) { ..... | ||
Line 248: | Line 248: | ||
Labels are given like this: | Labels are given like this: | ||
< | <syntaxhighlight lang="cpp"> | ||
Label1: | Label1: | ||
</source> | </source> | ||
Line 256: | Line 256: | ||
The [[AGIWiki/Goto|Goto]] command takes on parameter, the name of a label: | The [[AGIWiki/Goto|Goto]] command takes on parameter, the name of a label: | ||
< | <syntaxhighlight lang="cpp"> | ||
goto(Label1); | goto(Label1); | ||
</source> | </source> | ||
Line 264: | Line 264: | ||
There are three ways that comments can be used. | There are three ways that comments can be used. | ||
< | <syntaxhighlight lang="cpp"> | ||
// - rest of line is ignored | // - rest of line is ignored | ||
Line 274: | Line 274: | ||
The /*...*/ can be nested: | The /*...*/ can be nested: | ||
< | <syntaxhighlight lang="cpp"> | ||
/* comment start | /* comment start | ||
Line 304: | Line 304: | ||
In some cases you may want to assign a specific number to a message so you can refer to it in other places. This is done by using the #message command, followed by the number of the message then the message itself: | In some cases you may want to assign a specific number to a message so you can refer to it in other places. This is done by using the #message command, followed by the number of the message then the message itself: | ||
< | <syntaxhighlight lang="cpp"> | ||
#message 4 "You can't do that now." | #message 4 "You can't do that now." | ||
</source> | </source> | ||
Line 310: | Line 310: | ||
Then you can give the message number as the parameter in commands: | Then you can give the message number as the parameter in commands: | ||
< | <syntaxhighlight lang="cpp"> | ||
print(m4); | print(m4); | ||
</source> | </source> | ||
Line 316: | Line 316: | ||
Or embed the message in commands as normal and the number you assigned to it before will be used: | Or embed the message in commands as normal and the number you assigned to it before will be used: | ||
< | <syntaxhighlight lang="cpp"> | ||
print("You can't do that now."); | print("You can't do that now."); | ||
</source> | </source> |