Script Overview: Difference between revisions
Created page with "== Introduction == OpenBOR includes a C-based scripting engine that allows creators to build customized or all new functionality into their games. Scripts may execute in response to a wide range of engine events, including animation-frame updates, engine cycles, timer ticks, collisions, damage, key input, and many others. Creators can implement scripts through native define-file paths, user-defined libraries, or code inserted directly into level files and model sheets...." |
|||
| Line 9: | Line 9: | ||
== Basics == | == Basics == | ||
OpenBOR Script uses syntax similar to C, with several notable differences: | |||
Weak typing: OpenBOR Script is weakly typed. Variables are stored as variants, and the engine changes their types as needed. Type prefixes indicate the intended data type, but do not enforce it by default. Functions declared as void may still return values. Strong typing may optionally be enforced with type guards. See Variables and Type Guards for details. | |||
Preprocessor directives: Standard C preprocessor directives such as #include, #define, and #ifdef are available. OpenBOR Script also provides an additional #import directive. | |||
String concatenation: The + operator may be used to combine strings: | |||
"string1" + "string2" | |||
This returns: | |||
"string1string2" | |||
Assignment: During assignment, both the value and type of the right-hand variant are copied to the left-hand variant. No automatic type validation is performed, so creators should take care when assigning values between variables. | |||
[[Category:Openbor]] | [[Category:Openbor]] | ||
[[Category:OpenBOR Index]] | [[Category:OpenBOR Index]] | ||
[[Category:Script]] | [[Category:Script]] | ||
Revision as of 21:27, 12 July 2026
Introduction
OpenBOR includes a C-based scripting engine that allows creators to build customized or all new functionality into their games. Scripts may execute in response to a wide range of engine events, including animation-frame updates, engine cycles, timer ticks, collisions, damage, key input, and many others. Creators can implement scripts through native define-file paths, user-defined libraries, or code inserted directly into level files and model sheets.
Alongside its native function library, the OpenBOR scripting engine supports the #include directive. An optional, memory-efficient #import directive is also available when only function references are needed. These directives allow creators to build reusable custom libraries, then call their functions from any appropriate script event.
Scripts can also perform create, read, update, and delete operations on external data files at runtime. This includes working with content such as model sheets, configuration data, and even other script files.
In practical terms, OpenBOR places virtually no limit on the game mechanics creators can implement. If you can imagine it and write the logic, you can build it.
Basics
OpenBOR Script uses syntax similar to C, with several notable differences:
Weak typing: OpenBOR Script is weakly typed. Variables are stored as variants, and the engine changes their types as needed. Type prefixes indicate the intended data type, but do not enforce it by default. Functions declared as void may still return values. Strong typing may optionally be enforced with type guards. See Variables and Type Guards for details. Preprocessor directives: Standard C preprocessor directives such as #include, #define, and #ifdef are available. OpenBOR Script also provides an additional #import directive.
String concatenation: The + operator may be used to combine strings:
"string1" + "string2"
This returns:
"string1string2" Assignment: During assignment, both the value and type of the right-hand variant are copied to the left-hand variant. No automatic type validation is performed, so creators should take care when assigning values between variables.