engine
The running app: its clock, command-line args, user_data_dir, loaded plugins and quit.
On this page
The running app: its clock, command-line args, user_data_dir, loaded plugins and quit.
30 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. |
change_tick() -> int |
— | The change tick now, stepped before every system runs and never put back. Keep it where a script last looked, and scene.changed_since answers what moved after it. |
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. |
has_plugin(string) -> bool |
— | Whether one plugin loaded, so a game shipped without http can say so rather than call into a module that is not there. |
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. Not on iOS or Android yet, where it reports that it has no opener. 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. |
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_script(string) -> string |
— | Recompile one script by its project-relative key, for a tool editing files outside the watched root; answers what kept it from compiling, empty when it 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. |
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. |
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. |