Skip to content

Search

Documentation

engine module

The running app: its clock, command-line args, user_data_dir, loaded plugins and quit.

本页内容

The running app: its clock, command-line args, user_data_dir, loaded plugins and quit.

28 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() — The command-line arguments the app was started with, empty when it was given none.
dark_mode() — 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() — Seconds the frame in progress covers, the same number a system is handed.
device_id() — One id per install, made on first use and kept in the user directory: what a device login sends. Recorded with the session.
environment(name: string) -> string? — 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() — 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() — What each function has cost since set_script_profiling(true), dearest first: a list of { function, calls, instructions }, a function's own instructions without its callees'. A draw callback and a closure a native call runs are in it.
has_plugin(name: string) — 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(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() — Whether the game is paused.
plugin_version(name: string) — The version of one loaded plugin, or nil when it did not load.
plugins() — Every plugin this build loaded, named, in load order.
quit(code: 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(key: string) — Recompile one script by its project-relative key, for a tool editing files outside the watched root.
reveal(path: 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() — What each script has cost since set_script_profiling(true), dearest first: a list of { path, calls, instructions }. Instructions, not seconds, so the number is the same on every machine.
set_paused(on: 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(on) — Start or stop counting what each script costs. Turning it on clears the tally.
set_time_scale(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() — 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() — Which frame this is, counted whole: what simulation code branches on instead of time.
tick_hz() — How many fixed steps a second this run takes, from [time] tick_hz. 60 unless the project says otherwise.
time() — Seconds of engine time since the app started, accumulated as a float.
time_scale() — What time is being multiplied by; 1.0 is real time.
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() — 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() — A writable per-user directory for saves and settings, created on first call and named after the project.
user_data_directory_of(project: string) — The user data directory a project of that name has, not created: where a tool finds another game's saves and logs.