Skip to content

Scripting Overview#

Notice

This page is still work in progress and may contain inaccurate information.

In any project, you'll likely want to do more than just place some objects or create a static environment. Odds are, you'll want more intricate functionality - requiring new project-specific code, such as controlling a player character, implementing AI, having a more interactive and responsive world, and so on. To do this, you'll need to use scripts.

Scripts generally refer to a piece of game code that is tied to an object. Most scripts come in the form of Tag Scripts - which are scripts specifically designed to attach to a tag or tag instance. These scripts provide direct access to the tag and world object they are attached to, allowing for both the world object and tag data to be manipulated or read at runtime.

Currently, scripts can only be written in C++, though there are plans to offer C# and node graph scripting in the future.

Scripting Tag Classes#

While not always necessary, most projects will wish to implement their own custom tag classes to serve one purpose or another. Tag classes can optionally specify a default custom script, which can be used to provide base functionality for the tag class - such as creating a weapon class which automatically provides default functionality for projectiles, ammunition, and so on. These default scripts can also be extended by any tags using this class if desired - such as a special weapon type that requires additional functionality from other weapons - though this is also optional.

Any tag class, regardless of if it has a default script or not, can include any number of function fields that can be called by other scripts or game code. These functions can then be connected and used by any attached tag script. Additionally, some tag classes may support calling plain functions rather than script methods, for cases where there is only ever expected to be a single type of a particular tag loaded (such as a scenario), however using a script class is often still preferred in even these cases.

Global Scripts#

The engine also supports global scripts, which are scripts which are created (or persist) throughout the entire runtime of the application. These can be registered during the game_init() function, or added to the global scripts block within the project's globals tag. Additionally, the user may also attach a script directly to their project's globals tag, if desired.