BattleCore Standard Library

Overview

The BattleCore Standard Library is the set of device functions that BattleScript code uses to control the hardware and game state of a BattleCore device. These functions cover audio, lighting, infrared, networking, the finite state machine, player and weapon state, and more.

Unlike the language standard libraries (std::console, std::debug, std::gpio and std::math), the BattleCore API is not part of the BattleScript language itself. It is provided by the device firmware, and is split into modules that each expose a focused set of native functions.

Namespacing

Every BattleCore function is namespaced under the lowercase battlecore namespace, followed by the module name and the function name:

battlecore::<module>.<fn>(...)

// for example
battlecore::weapon.fire();
battlecore::player.takeDamage(10);
battlecore::fsm.setState(StateEnum.HOME);

Including the declarations

Because the BattleCore functions are provided by the firmware rather than the language, their declarations are pulled into your program by include-ing the matching declaration file for the module you want to use:

include "./battlecore/player.bst";
include "./battlecore/weapon.bst";

// the declarations are now available to call
battlecore::player.respawn();

The include statement is a textual include of another .bst file. It is how the native declarations and shared enums for each module become visible to your code. This is distinct from the language standard libraries, which are globally available and require no include or import.

Modules

The BattleCore Standard Library is made up of the following modules:

Reference

  • Device Events — every event a device emits to your script, and the payload each one carries.