Skip to content

Search

Documentation

engine

The running app: its clock, command-line args, user_data_dir, loaded plugins, quit, and store for state no node owns.

On this page

The running app: its clock, command-line args, user_data_dir, loaded plugins, quit, and store for state no node owns.

31 functions, 0 constants. Scripts reach it as engine::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
args() -> [str] — The command-line arguments the app was started with, empty when it was given none.
dark_mode() -> bool — Whether the system is in dark mode this tick; every script's on_dark_mode_changed(bool) is called when it changes. False where nothing says.
delta() -> float — Seconds the frame in progress covers, the same number a system is handed.
device_id() -> string — One id per install, made on first use and kept in the user directory: what a device login sends. Recorded with the session.
environment(string) -> str? — An environment variable's value, nil when it is unset. Nil on the web, which has none. Outside the simulation, like args: a replay does not record it.
focused() -> bool — Whether the window is in front of the player this tick; every script's on_focused_changed(bool) is called when it changes. True with no window.
function_costs() -> [engine::FunctionCost] — What each function has cost since set_script_profiling(true), dearest first: a list of { function, calls, instructions }, a function's own statements without its callees'. A function of a module two files use counts once for the two.
open_url(string) — Open an http, https or mailto URL in whatever the player browses with: an opener on a desktop, a new tab on the web, the browser on a phone. An effect on the world outside the game: never recorded, and it does nothing while a recording plays.
paused() -> bool — Whether the game is paused.
plugin_version(string) -> str? — The version of one loaded plugin, or nil when it did not load: how a game shipped without http says so rather than call into a module that is not there.
plugins() -> [str] — Every plugin this build loaded, named, in load order.
quit(int?) — Ask the app to shut down; the frame in flight still finishes, and the process exits with code, 0 when left out.
reload_scripts([str]) -> string — Recompile scripts by their project-relative keys in one build, however many there are, for a tool editing files outside the watched root; answers what kept them from compiling, empty when they did.
reveal(string) — Show a file or directory in the system file manager, selected where the platform can. Desktops only: neither a browser tab nor a phone has a file manager to ask. Never recorded, like open_url.
script_costs() -> [engine::ScriptCost] — What each script has cost since set_script_profiling(true), dearest first: a list of { path, calls, instructions }, calls the engine's calls into it. A file counts the statements it ran: not seconds, so the number is the same on every machine.
set_content_root(string) — Play the content of the project at root: its strings/ catalogues and its fonts/ are read from there, and the subtree debugger.set_scope names draws in them. For a host running a project other than its own: the editor, whose own root has neither. An empty string plays the project's own again.
set_paused(bool) — Pause or resume the game. Every node whose process mode is pausable stops ticking, physics holds both worlds, and the frame loop keeps drawing; an always subtree is what a pause menu runs in. Every script's on_paused_changed(bool) follows, the ones the pause just stopped included.
set_script_profiling(bool) — Start or stop counting what each script costs. Turning it on clears the tally; on from off, or off from on, rebuilds every Balaur Script file between frames, with counters or without, carrying its fields across.
set_time_scale(float) — Multiply wall-clock time before the simulation is owed it: 0.5 is slow motion, 2.0 fast forward, each still whole fixed steps. Zero stops time without stopping a single node. A replay and a networked session drive by tick and ignore it.
store(string, any) — Keep any value under a key for as long as the app runs: state no node owns, like a class's static variable.
stored(string) -> any — What store kept under a key; nil when nothing was.
target() -> engine::Target — Where this runs: { os, web, mobile, touchscreen, editor, dev }, dev being a run from the sources rather than an exported pack. Recorded in a session's header, so a replay on another machine answers as the original did.
tick() -> int — Which frame this is, counted whole: what simulation code branches on instead of time.
tick_hz() -> int — How many fixed steps a second this run takes, from [time] tick_hz. 60 unless the project says otherwise.
time() -> float — Seconds of engine time since the app started, accumulated as a float.
time_scale() -> float — What time is being multiplied by; 1.0 is real time.
timings() -> engine::Timings? — What the last frame cost, in seconds: { frame, fixed_steps, stages, spans }. Presentation only: branching a fixed_update on wall time desyncs, and nothing records it.
unix_time() -> float — The wall clock at the top of this tick, in seconds since 1970. Read once per frame and recorded, so a replay sees the time the recording saw.
user_data_directory() -> string — A writable per-user directory for saves and settings, created on first call and named after the project. A game the editor plays answers with its own, the folder it has when run alone.
user_data_directory_of(string) -> string — The user data directory a project of that name has, not created: where a tool finds another game's saves and logs.
watch(string, [str]) -> bool — Follow a directory outside the project the way a run follows the project: a script loaded from it hot reloads when its file changes. A script hears each burst of changes once with events::listen(this.node, "files_changed"), as on_files_changed(paths), each path spelled from directory and with one of extensions, or any file when that is empty. An empty list is more than the watcher could name, so what is held has to be checked again. Answers false where nothing can be followed: a pack, a browser, a run with watching off. The directory has to be one fs may reach.

Are you sure?