Sign in
creature

Moon jellies

by Potluck · version 1 · Checked for all ages

Pale jellyfish that drift and pulse in deep water and glow softly, so the sea fills with little lights after dark. Don't swim into one in survival: it stings a little, though never too much. Bop one and it drifts away.

1--!strict
2-- Moon jellies' own tests: `potluck-server --test=moon-jellies`.
3local test = require("@potluck/test@0.9")
4local world = require("@potluck/world@0.31")
5
6local UP = vector.create(0, 1, 0)
7
8local function pool(depth: number): vector
9 local g = world.spot("green")
10 local cx, cz, y = math.floor(g.x) + 80, math.floor(g.z), 90
11 for dx = -14, 14 do
12 for dz = -14, 14 do
13 local edge = math.abs(dx) == 14 or math.abs(dz) == 14
14 world.set_block(vector.create(cx + dx, y, cz + dz), "Stone")
15 for dy = 1, depth do
16 world.set_block(vector.create(cx + dx, y + dy, cz + dz), if edge then "Stone" else "Water")
17 end
18 end
19 test.wait(0)
20 end
21 return vector.create(cx + 0.5, y + 1, cz + 0.5)
22end
23
24local function jellies(): { number }
25 return world.creatures(test.kind("Moon jelly"))
26end
27
28test.case("jellies drift in deep water at night, and stay in it", function()
29 test.daytime(0)
30 local p = test.player("Ada")
31 local floor = pool(6)
32 test.move(p, floor + vector.create(0, 7, 0))
33 test.wait(15)
34 test.check(#jellies() >= 2, "jellies came")
35 for _, id in jellies() do
36 local j = test.creature(id)
37 test.same(world.block(j.position + UP * 0.3), "Water", "in the water")
38 end
39end)
40
41test.case("swim into one and it stings, but not too much", function()
42 local p = test.player("Ada", { survival = true })
43 local floor = pool(5)
44 test.move(p, floor + vector.create(4, 2, 0))
45 local id = world.spawn(test.kind("Moon jelly"), floor + vector.create(0, 2, 0))
46 test.wait(0.2)
47 for _ = 1, 20 do
48 local j = test.creature(id)
49 test.move(p, j.position - UP * 0.4)
50 test.wait(0.5)
51 end
52 test.check(test.health(p) < 20, "it stung")
53 test.check(test.health(p) >= 6, "but never below six")
54 test.check(test.heard("sting") >= 1, "with a fizz")
55end)