Sign in
world

The Long Dusk

by Potluck · version 1 · Checked for all ages

The sun never moves in the Long Dusk. Make a Dusk mirror (glass, gold and crystal, at the Workbench) and use it to step into the Gold, where duskwood hangs with ember pods and lanternbacks graze. West lie the salt flats of the Glare, where glints wait and sunstone runs under the crust; east, the Gloaming and the Long Night, frozen under the stars, where starglass grows and hushers drift. Sunstone, starglass and moonsilver make evensteel. A mirror waits where you came out, to take you home.

1--!strict
2-- The Long Dusk's own tests: `potluck-server --test=long-dusk`.
3local test = require("@potluck/test@0.9")
4local world = require("@potluck/world@0.33")
5
6local function v(x: number, y: number, z: number): vector
7 return vector.create(x, y, z)
8end
9
10-- where a player is now
11local function pos(p): vector
12 for _, q in world.players() do
13 if q.id == p.id then
14 return q.position
15 end
16 end
17 error("no such player")
18end
19
20-- dry ground in one of the Long Dusk's lands, from west of it eastward
21local function land(name: string, from: number): vector
22 for x = from, from + 3000, 37 do
23 local at = v(x + 0.5, 0, 140.5)
24 local top = world.top(at.x, at.z)
25 if world.biome(at) == name and top > 20 then
26 return v(at.x, top + 1.02, at.z)
27 end
28 end
29 error("no " .. name .. " found")
30end
31
32local function count(kind: string): number
33 return #world.creatures(test.kind(kind))
34end
35
36test.case("a mirror at home goes to the Gold, and the one there comes back", function()
37 local g = world.spot("green")
38 local p = test.player("Ada", { survival = true, carrying = { ["Dusk mirror"] = 1 } })
39 local at = v(math.floor(g.x) + 6, world.top(g.x + 6, g.z) + 1, math.floor(g.z))
40 test.move(p, at + v(0.5, 0, 2.5))
41 test.place(p, at, "Dusk mirror", "north")
42 test.use_block(p, at)
43 test.wait(1)
44 local there = pos(p)
45 test.same(world.place(there), "dusk", "through to the Long Dusk")
46 test.same(world.biome(there), "gold", "out in the Gold")
47 test.check(world.daylight(there) > 0.2, "where the sun is up")
48 local m = world.find_block(there, 4, "Dusk mirror")
49 test.check(m, "a mirror to go back by")
50 test.check(world.find_block(there, 5, "Sun lamp"), "with sun lamps by it")
51 test.check(test.shown(p, "dusk") ~= nil, "and the land's name said")
52 if not m then
53 return
54 end
55 test.use_block(p, m)
56 test.wait(1)
57 local back = pos(p)
58 test.same(world.place(back), "home", "home again")
59 test.check(vector.magnitude(back - at) < 3, "by the mirror they went through")
60 -- and the same pair the next time
61 test.use_block(p, at)
62 test.wait(1)
63 test.check(vector.magnitude(pos(p) - there) < 3, "through to the same mirror")
64end)
65
66test.case("a mirror put down in the dusk goes to the Green", function()
67 local p = test.player("Ada")
68 local at = land("gold", 24000)
69 test.move(p, at)
70 local m = at + v(2, 0, 0)
71 test.place(p, m, "Dusk mirror")
72 test.use_block(p, m)
73 test.wait(1)
74 test.same(world.place(pos(p)), "home", "home")
75 test.check(vector.magnitude(pos(p) - world.spot("green")) < 4, "on the Green")
76end)
77
78test.case("sunstone, starglass and nightglass need their pickaxes", function()
79 local p = test.player("Ada", { survival = true, carrying = { ["Evensteel pickaxe"] = 1 } })
80 local at = land("glare", 21000)
81 test.move(p, at)
82 local here = pos(p)
83 for i, name in { "Sunstone ore", "Starglass", "Nightglass" } do
84 local b = here + v(1, 0, i - 2)
85 world.set_block(b, name)
86 test.hold(p, nil)
87 test.check(not test.dig(p, b), name .. " doesn't break by hand")
88 test.hold(p, "Evensteel pickaxe")
89 test.check(test.dig(p, b), name .. " breaks under evensteel")
90 end
91 test.check(world.has(p, "Sunstone") >= 1, "sunstone given")
92 test.check(world.has(p, "Starglass shard") >= 1, "starglass shards given")
93 test.check(world.has(p, "Nightglass") >= 1, "nightglass given")
94 local ember = here + v(-1, 1, 0)
95 world.set_block(ember, "Ember pod")
96 test.dig(p, ember)
97 test.check(world.has(p, "Ember fruit") >= 1, "an ember pod gives ember fruit")
98end)
99
100test.case("glints wait on the salt and bite whoever comes near", function()
101 test.danger("normal")
102 local p = test.player("Ada", { survival = true })
103 test.move(p, land("glare", 21000))
104 test.wait(8)
105 local ids = world.creatures(test.kind("Glint"))
106 test.check(#ids >= 1, "glints came")
107 local g = test.creature(ids[1])
108 if not g then
109 return
110 end
111 test.move(p, g.position + v(2, 0.5, 0))
112 test.wait(6)
113 test.check((test.health(p) or 20) < 20, "and one bit")
114 g = test.creature(ids[1])
115 if g then
116 for _ = 1, 3 do
117 test.hit(p, g)
118 end
119 test.check(world.has(p, "Glint scale") >= 1, "a broken one leaves its scales")
120 end
121 test.danger("peaceful")
122 test.wait(4)
123 test.same(count("Glint"), 0, "none on Peaceful")
124end)
125
126test.case("hushers come in the Long Night's dark and keep off light", function()
127 test.danger("normal")
128 local p = test.player("Ada", { survival = true })
129 local at = land("long_night", 26000)
130 test.move(p, at)
131 test.check(world.daylight(at) < 0.1, "the Long Night is dark")
132 test.wait(10)
133 test.check(count("Husher") >= 1, "hushers came")
134 test.wait(25)
135 test.check((test.health(p) or 20) < 20, "and one touched")
136 world.set_block(pos(p) + v(1, 0, 0), "Lantern")
137 test.wait(8)
138 for _, id in world.creatures(test.kind("Husher")) do
139 local h = test.creature(id)
140 test.check(not h or vector.magnitude(h.position - pos(p)) > 4, "they keep off the lantern")
141 end
142 local hurt = test.health(p) or 20
143 test.wait(10)
144 test.same(test.health(p) or 20, hurt, "and touch nobody by it")
145end)
146
147test.case("lanternbacks graze in the Gold, and none come home", function()
148 local p = test.player("Ada")
149 test.move(p, land("gold", 24000))
150 test.wait(8)
151 test.check(count("Lanternback") >= 1, "lanternbacks in the Gold")
152 local g = world.spot("green")
153 test.move(p, v(g.x, world.top(g.x, g.z) + 1, g.z))
154 test.wait(30)
155 test.same(count("Lanternback"), 0, "they stay in the Long Dusk")
156end)