Skip to content

Field manual / Level editor

Built-in functions

Every function the engine gives to OG Script and Classic scripts, by package. The same descriptions appear in the editor's Reference (F1) and in its code completion. The full language is described in the OG Script language reference.

The table is src/builtins.zig: 141 entries, each with a Classic name (the exe name, which Classic scripts use) and an OG Script name. In OG Script, built-ins live in 12 reserved packages (134 functions), and the root holds a core of three (print, str, EqualsIgnoreCase); three Classic functions are not needed in OG Script (§16.14). Descriptions are in src/editor/api.zig. A signature is written the way the table prints it: result(parameter types), where ? marks an optional parameter and any means any value (including the result of a script function). A bool result is a yes/no answer: true/false in OG Script, int 1/0 in Classic (§4).

  • Name. In OG Script a built-in is called through its package: fighter::SetHp(host, 1), or the package is opened: use fighter; and then SetHp(host, 1) (§8.2). A Classic name (FighterSetHp) in OG Script is a link error with a hint about the path. Classic scripts use the exe names, as before; translation between Classic and OG Script (the OG Script view in the editor, §20) maps names using this same table.
  • The types in a signature are documentation. They are not yet checked on calls from OGS (planned: checking at link time). The number of arguments is not checked either (§8.1). The exception is the kind types level, scene, sound: they are strings, and a sigil of another kind there is a link error (§6.8). The method type is the name of a method of the calling component and is checked at link time (§14.1). A final parameter type name... takes all arguments from its position onward (events::Emit).
  • Parameter names exist only for OpenGorky-only functions (the signature names the parameters). Only these functions accept arguments by name.
  • Most functions are functions of the original game, with its behavior. Many of them are meant for Classic object creation events (registering animations) or for an actor's command queue. In battle handlers, the meaningful packages are mainly battle, fighter and events.
  • Where an object name is expected, you can pass a reference (host, @grandma, attacker).

Packages

Root: the coreNo package; usable in any code.
object::Objects. Any object by name: whether it exists, enable, disable, delete, its classic_id and class, calling its function.
sound::Sound. Sounds and ambient.
actor::Actor. Actor: registering the model and animations (creation events), the command queue, state, attachment and link points.
path::Path scripts. Path script (.pth) functions: they act on the path node's actor — not on host, and without an actor argument.
level::Level. Level: loading, the level counter (progress), the walk map, floors, global strings.
hero::Party. The hero party: the selected hero, who is in the party, enabling and placing heroes, whether any hero has something.
scene::Scenes and video. Everything that plays "like a movie": scenes, dialogs, video, fades, the caption.
gui::Interface. Interface modes: panorama, scene mode, mode selection.
item::Items and weapons. Items and weapons.
battle::Battle. The battle as a whole: tiles, turns, the bomb, battle variables, spawning fighters, victory and defeat.
fighter::Fighter. A single fighter: health, level, skills, AI, damage, states, transformation.
events::Events. The event bus between components (§14.1).
Classic onlyThese original functions have no OG Script name: the same thing is done differently.