The tutorial's sun waits for you (Gitea #5): the afternoon goes no later than 16:30 until the torch step brings dusk

This commit is contained in:
Paul Bailey
2026-11-08 20:19:15 +00:00
parent 5672f0713d
commit 07b8db1683
2 changed files with 39 additions and 0 deletions

View File

@@ -324,12 +324,34 @@ func _process(delta: float) -> void:
if d > 0.01 and d < 5.0: # (not a teleport or a respawn)
_count("walk", d)
_last_pos = p
hold_daylight()
_marker_t -= delta
if _marker_t <= 0.0:
_marker_t = 0.5
_marker = find_marker()
poll()
## The sun waits for you (Gitea #5): until a step that sets the clock comes
## up (the torch step, at dusk), the afternoon goes no later than
## DAYLIGHT_UNTIL, however long the earlier steps take. Then dusk comes on
## when the tutorial means it to.
const DAYLIGHT_UNTIL := 16.5
func hold_daylight() -> void:
if not active or world == null or not is_instance_valid(world) or world.day_night == null:
return
if _clock_step_reached():
return
var latest := DAYLIGHT_UNTIL / 24.0
if world.day_night.time > latest:
world.day_night.time = latest
## Whether the current step, or one before it, moves the clock on.
func _clock_step_reached() -> bool:
for i in range(mini(index + 1, steps.size())):
if Dictionary(steps[i].get("setup", {})).has("time"):
return true
return false
## Goals that are states, not events: checked twice a second.
func poll() -> void:
if not active or world == null or not is_instance_valid(world):

View File

@@ -135,6 +135,23 @@ func _starts() -> void:
"\"%s\" / \"%s\"" % [pn._chapter.text, pn._title.text])
check(G.guide_name == "Old Tam" and pn._text.text.begins_with("Old Tam: \""), "Old Tam the hermit talks you through it: %s" % pn._text.text)
check(G.find_marker() == Vector3.INF, "(no marker for that one)")
# Gitea #5: the sun waits for you until the torch step brings dusk.
var dn: Node = world.day_night
var t0: float = dn.time
dn.time = 19.0 / 24.0
G.hold_daylight()
check(absf(dn.time * 24.0 - G.DAYLIGHT_UNTIL) < 0.01, "early in the tutorial the afternoon goes no later than %.1f h (%.2f)" % [G.DAYLIGHT_UNTIL, dn.time * 24.0])
var torch_i := -1
for i in range(G.steps.size()):
if String(G.steps[i].id) == "torch":
torch_i = i
var was_i: int = G.index
G.index = torch_i
dn.time = 19.0 / 24.0
G.hold_daylight()
check(torch_i > 0 and absf(dn.time * 24.0 - 19.0) < 0.01, "from the torch step on, night comes as usual")
G.index = was_i
dn.time = t0
func _chapter_one() -> void:
print("1. look around")