OpenBOR supports a C based scripting engine that allows creators to code customized functionality into their games. Script functions are executed by a variety of engine events, including animation frame updates, engine cycle updates, timer ticks, collisions, damage, key inputs, and much more. Creators may insert script code directly into level texts or model sheets.
In addition to a suite of native functions, the OpenBOR scripting engine also supports the #include directive. Optionally, a memory saving #import is available to only include function references. These directives enable creators to define their own custom function libraries to call and execute as needed from trigger events. The engine also supports CRUDing (Create, Read, Update, Delete) data files on the fly (including items like model sheets or even other scripts).
In short, there is virtually no limit at all to game mechanics. If you want it, and you can imagine it, then you can create it!
Basics
Syntax
OpenBOR script is similar to c syntax, with a few notable differences:
- OpenBOR Script is weak typed. The engine will retype variants as needed (see Variables). Type prefixes only tell the engine it is a data type. Functions can return values even if they are void type.
- The standard C preprocessor directives (#include, #define, #ifdef, etc.) are available. There is also an additional directive called #import.
- String concatenation. You can use + operator to combine strings:
"string1" + "string2"
returns"string1string2"
. - Assignment. The right variant’s value and type will be copied to the left variant. No type checking, so be careful.
Operators
- +
- –
- *
- /
- %
- =
- &
- +=
- -=
- /=
- *=
- %=
- !
- ==
- ||
- &&
- !=
- >
- <
- >=
- <=
- |
- <<
- >>
- ^
- ~
Identifiers
- do
- while
- for
- break
- if
- else
- continue
Directives
- #define
- #ifndef
- #endif
- #include
- #import – Custom implementation. Imports function references without copying contents of file.
Events
Events are triggers in the engine that cause OpenBOR to run a loaded script. When the event occurs, OpenBOR populates a set of predefined local variables and executes the script’s main() function.
Under construction