Scene
Switching between scenes. A request is deferred: the world is replaced after the current frame's scripts finish, so call it freely from any hook. The runtime app handles requests; other hosts may not. A scene change removes every entity, so keep data you need in `caffeine.session`.
Namespace: caffeine.scene · Dryad prefix: caffeine_scene_
load#
Lua: caffeine.scene.load · Dryad: caffeine_scene_load
load(path)
Asks the host to load a scene, replacing the current one. A missing or unreadable file is reported and the current scene stays.
| Parameters | Type | Description |
|---|---|---|
path | string | Scene file, relative to the project root or absolute. |
Returns: none
Example
if caffeine.session.get("coins") >= 10 then caffeine.scene.load("scenes/win.scene") end
reload#
Lua: caffeine.scene.reload · Dryad: caffeine_scene_reload
reload()
Reloads the current scene from disk, resetting it to its saved state.
Returns: none
Example
caffeine.scene.reload() -- restart the level
current#
Lua: caffeine.scene.current · Dryad: caffeine_scene_current
current() -> string
Returns the loaded scene.
Returns: string. The path of the loaded scene as given to the host (empty when unknown).
Example
caffeine.debug.log(caffeine.scene.current())
isLoading#
Lua: caffeine.scene.isLoading · Dryad: caffeine_scene_is_loading
isLoading() -> boolean
Tells whether a scene change is waiting to happen.
Returns: boolean. true after load or reload was requested and before the host handled it.
Example
if caffeine.scene.isLoading() then return end