Skip to content
Érico Vieira Porto edited this page Feb 24, 2019 · 10 revisions

Preprocessor

Before the AGS Script compiler is ran, an AGS Preprocessor runs, which will modify the script file before it's passed on for the compiler.

define Macro

#define <macro> <value>

Define is a Macro, you can think of a way to tell the processor that, whenever the defined name is encountered, it should be replaced by the value or content that follows. It's similar to a variable with a set initial value, but this variable has no type and accepts anything. You can check if a Macro is defined using #ifdef preprocessor keyword.

ifdef Macro test

#ifdef <macro> #ifndef <macro>

Test if macro is defined or undefined.

ifver Version Checking

If you are writing a script module, you may need to check which version of AGS the user of your module is using. For this purpose there are two directives:

#ifver <version> #ifnver <version>

Note that this ability was only added in 2.72, so you cannot use the #ifver checks if you want your module to work with earlier versions than this. Example:

#ifver 2.72
// do stuff for 2.72 and above
#endif
#ifnver 2.72
// do stuff for 2.71 and below
#endif

See also: Version Checking Keyword

region code folding

#region
  // some code
#endregion

You can wrap a code between lines containing #region and #endregion to create a section used for code folding. In the AGS Editor you can use this to hide sections of your code you don't need to see by using the + button at the left side of the script editor.

error throw compile error

#error User defined compile-time error (with message).

legacy commands

#sectionstart
#sectionend

These two preprocessor commands do nothing, they are ignored legacy commands from pre-3 era. They are valid keywords so there you have it.

See: Scripting Languange

Getting Started in AGS

Introduction

Frequently Asked Questions

Tutorial

Editor Reference

Room Editor

Character Editor

GUI Editor

Sprite Manager

View Editor

Inventory Items Editor

Other Features

Engine

The run-time engine

Graphics driver selection

Engine Setup Program

Scripting

Scripting Language

Scripting API

Reference

Working on Legacy games

Upgrading from a previous version

Legal Notice

Copyright and terms of use

Anonymous usage information

Credits

Getting in touch

Contacting the developers

Clone this wiki locally