Changes

Jump to navigation Jump to search
No change in size ,  20:50, 11 May 2016
Fix syntax highlighting
'''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 <syntax typesource lang="C++cpp">#define</syntaxsource> command. The name of the define is given, followed by the define value:<syntax typesource lang="C++cpp">
#define ego o0
#define roomDescription "This is a large hall with tall pillars down each side."
</syntaxsource>
Then the define name can be used in place of the define value:
<syntax typesource lang="C++cpp">
draw(ego);
print(roomDescription);
</syntaxsource>
'''Note:''' The rules for defines vary depending on the compiler. The following discussion applies to the [[AGIWiki/AGI Studio|AGI Studio]] compiler.
Below is a typical [[AGIWiki/New room section|new room section]] of a logic file, without defines:
<syntax typesource lang="C++cpp">
if (f5)
{
}
</syntaxsource>
The same code, using defines, might appear like the following:
<syntax typesource lang="C++cpp">
#define new_room f5
#define room_no v0
show.pic();
}
</syntaxsource>
The AGI Studio compiler allows you to place the <code><nowiki>#define</nowiki></code> commands in a separate file and then use those defines in multiple logics without having to redefine them all again. See [[AGIWiki/Includes|includes]] for more details.
TrustedUser
2,000

edits

Navigation menu