Skip to content

Includes

It is possible include the content of a file in another file using the include directive.

Syntax of the include directive

include "path/to/file.xs";

In a script, the include directive is replaced by the content of the corresponding file.

Example of file inclusion

Let's say foo.xs contains the following code and is placed in the same folder as Age3AI.xs:

foo.xs
1
2
3
4
void foo(void)
{
    aiEcho("Hello from foo!");
}

We can include it like this:

Age3AI.xs
1
2
3
4
5
6
include "./foo.xs";

void main(void)
{
    foo();
}

Which will ultimately look like this once the game is done putting files together:

Age3AI.xs
1
2
3
4
5
6
7
8
9
void foo(void)
{
    aiEcho("Hello from foo!");
}

void main(void)
{
    foo();
}

Absolute and relative paths are both supported.

Absolute paths start at the AI Root Folder.