Keep time while the player can act
13 / SCRIPT 5 OF 5
1. Script ID: reserve_timer. Name it Reserve Timer. This time check Global Script › Keep global instance alive. Paste the code, validate, apply and save. It runs while either character is active. Leave it unattached to the room objects.
var fraction := 0.0func _process(delta):
if Runtime == null: return var left = int(Runtime.variables.get("lift_seconds", 0))
if left <= 0: fraction = 0.0
return
if not Runtime.ready_for_input or Runtime.input_locked:
return
fraction += delta var whole := int(fraction)
if whole > 0:
fraction -= whole
await SetVariable({"name": "lift_seconds", "value": maxi(0, left - whole)})2. Understand the countdown. PCA calls _process each frame. delta is the sliver of time since the last frame. The script collects those slivers and removes whole seconds from lift_seconds. Otherwise a fast computer could empty the bar faster than a slow one.
While the runtime is preparing the next room or has locked player input, the count waits. The save slot holds the remaining whole seconds, so loading a slot resumes from that number. Reaching zero empties the reserve and leaves the repair in place.
[1] Validate the script. [2] Apply Changes, then Save Project in the main toolbar.
If the bar stays full, first check the global checkbox on Reserve Timer. If Pip’s cabinet says there’s no reserve while the bar still looks full, check the progress element’s variable binding on page 8.
