Difference between revisions of "Includes"

From AGI Wiki
Jump to navigationJump to search
(Created page with "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,...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[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:
+
[[Includes]], in [[Logic|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:
  
 
<div class="CodeBlockHeader">AGI Code:</div>
 
<div class="CodeBlockHeader">AGI Code:</div>
Line 50: Line 50:
  
 
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.
 
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.
 +
 +
==<br /> References ==
 +
 +
<references />
 +
 +
==<br /> Related Links ==
 +
 +
*
 +
 +
[[Category:AGI Logic]]

Latest revision as of 13:58, 30 January 2024

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:

AGI Code:

<syntaxhighlight lang="agi">

  1. define ego_on_water f0
  2. define new_room f5
  3. define score v3</syntaxhighlight>

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:

AGI Code:

<syntaxhighlight lang="agi">

  1. include "file.txt"

if (new_room) {

   // do new room stuff here

}

if (ego_on_water) {

   score++;

}</syntaxhighlight>

would be seen by the compiler as:

AGI Code:

<syntaxhighlight lang="agi">

  1. define ego_on_water f0
  2. define new_room f5
  3. define score v3

if (new_room) {

   // do new room stuff here

}

if (ego_on_water) {

   score++;

}</syntaxhighlight>

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.


References



Related Links