TrustedUser
2,147
edits
(Fix syntax highlighting) |
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=") |
||
Line 3: | Line 3: | ||
'''Defines''', in [[AGIWiki/AGI|AGI]] [[AGIWiki/Logic|logic]], allow you to provide a proper name for the [[AGIWiki/Variable|variables]], [[AGIWiki/Flag|flags]], [[AGIWiki/Animated object|objects]] and other data in the game. This significantly improves the readability of the code. | '''Defines''', in [[AGIWiki/AGI|AGI]] [[AGIWiki/Logic|logic]], allow you to provide a proper name for the [[AGIWiki/Variable|variables]], [[AGIWiki/Flag|flags]], [[AGIWiki/Animated object|objects]] and other data in the game. This significantly improves the readability of the code. | ||
To create a define name, use the < | To create a define name, use the <syntaxhighlight lang="cpp">#define</source> command. The name of the define is given, followed by the define value: | ||
< | <syntaxhighlight lang="cpp"> | ||
#define ego o0 | #define ego o0 | ||
#define roomDescription "This is a large hall with tall pillars down each side." | #define roomDescription "This is a large hall with tall pillars down each side." | ||
Line 10: | Line 10: | ||
Then the define name can be used in place of the define value: | Then the define name can be used in place of the define value: | ||
< | <syntaxhighlight lang="cpp"> | ||
draw(ego); | draw(ego); | ||
print(roomDescription); | print(roomDescription); | ||
Line 25: | Line 25: | ||
Below is a typical [[AGIWiki/New room section|new room section]] of a logic file, without defines: | Below is a typical [[AGIWiki/New room section|new room section]] of a logic file, without defines: | ||
< | <syntaxhighlight lang="cpp"> | ||
if (f5) | if (f5) | ||
{ | { | ||
Line 38: | Line 38: | ||
</source> | </source> | ||
The same code, using defines, might appear like the following: | The same code, using defines, might appear like the following: | ||
< | <syntaxhighlight lang="cpp"> | ||
#define new_room f5 | #define new_room f5 | ||
#define room_no v0 | #define room_no v0 |