Difference between revisions of "AGIWiki/Includes"

From ScummVM :: Wiki
Jump to navigation Jump to search
(Created page with "{{AGIWiki}} '''Includes''', in AGI logic, allow you to add the text of a file to another file by simply referencing the file name. This is done...")
 
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=")
 
(2 intermediate revisions by 2 users not shown)
Line 16: Line 16:
When the compiler encounters the above line, it will replace it with the contents of "file.txt". So, the following logic file:
When the compiler encounters the above line, it will replace it with the contents of "file.txt". So, the following logic file:


<syntax type="C++">
<syntaxhighlight lang="cpp">
  #include "file.txt"
  #include "file.txt"


Line 29: Line 29:
  }
  }


</syntax>
</syntaxhighlight>
would be seen by the compiler as:
would be seen by the compiler as:
<syntax type="C++">
<syntaxhighlight lang="cpp">
  #define ego_on_water f0
  #define ego_on_water f0
  #define new_room    f5
  #define new_room    f5
Line 45: Line 45:
     score  ;
     score  ;
  }
  }
  </syntax>
  </syntaxhighlight>


'''Note:''' [[AGIWiki/AGI Studio|AGI Studio]] requires include files to be in the "src" directory for the game.
'''Note:''' [[AGIWiki/AGI Studio|AGI Studio]] requires include files to be in the "src" directory for the game.

Latest revision as of 15:11, 25 October 2018

AGIWiki


Includes, in AGI logic, allow you to add the text of a file to another file by simply referencing the file name. This is done using the #include command. For example, if you have a file called "file.txt", which contains the following:

 #define ego_on_water f0
 #define new_room     f5
 #define score        v3
 

You can use the #include command as follows:

#include "file.txt"
 

When the compiler encounters the above line, it will replace it with the contents of "file.txt". So, the following logic file:

 #include "file.txt"

 if (new_room)
 {
     // do new room stuff here
 }

 if (ego_on_water)
 {
     score  ;
 }

would be seen by the compiler as:

 #define ego_on_water f0
 #define new_room     f5
 #define score        v3

 if (new_room)
 {
     // do new room stuff here
 }

 if (ego_on_water)
 {
     score  ;
 }

Note: AGI Studio requires include files to be in the "src" directory for the game.

It is a good idea to have all the defines that you need for multiple logics in an include file, so if you need to change the define value you only have to do it once (although you will need to recompile all logics that use that define). The AGI Studio Template Game provides a file like this called defines.txt.

Note: when you change a define value in an include file, AGI Studio does not automatically ensure that all logics that use the define are recompiled. You will need to recompile the logics manually, or use a development environment that will recompile all of the logics for you.