Sign in
creature

Pilferlings

by Potluck · version 1 · Checked for all ages

Sneaky little night thieves with big round eyes and a sack on their backs. Out on the grass at night in survival, one creeps up, snatches a few of whatever you're carrying (never your tools, gear or treasures) and runs off giggling. Catch it and bop it twice and you get it all back, sometimes with beads it stole from someone else, and now and then a silver thimble the Curator would love. If it gets away, it's gone. A light keeps them off. None on a Peaceful world.

1--!strict
2-- Pilferlings' own tests: `potluck-server --test=pilferlings`.
3local test = require("@potluck/test@0.9")
4local world = require("@potluck/world@0.26")
5
6local function pilferlings(): { number }
7 return world.creatures(test.kind("Pilferling"))
8end
9
10-- a grassy field high in the sky, away from the Green and its lights
11local function field(): vector
12 local g = world.spot("green")
13 local cx, cz, y = math.floor(g.x) + 90, math.floor(g.z), 90
14 for dx = -24, 24 do
15 for dz = -24, 24 do
16 world.set_block(vector.create(cx + dx, y, cz + dz), "Grass")
17 end
18 test.wait(0)
19 end
20 return vector.create(cx + 0.5, y + 1, cz + 0.5)
21end
22
23test.case("at night one creeps up, takes something and runs, and caught gives it back", function()
24 test.danger("normal")
25 test.daytime(0)
26 local p = test.player("Ada", { survival = true, carrying = { Cobblestone = 10 } })
27 test.move(p, field())
28 for _ = 1, 30 do
29 test.wait(2)
30 if world.has(p, "Cobblestone") < 10 then
31 break
32 end
33 end
34 test.check(world.has(p, "Cobblestone") < 10, "it took some cobblestone")
35 local ids = pilferlings()
36 test.check(#ids >= 1, "and it's still about")
37 local thief = test.creature(ids[1])
38 test.hit(p, thief)
39 test.hit(p, thief)
40 test.same(test.creature(ids[1]), nil, "caught")
41 test.same(world.has(p, "Cobblestone"), 10, "and it all came back")
42end)
43
44test.case("it never takes tools or gear", function()
45 test.danger("hard")
46 test.daytime(0)
47 local p = test.player("Ada", { survival = true, carrying = { ["Iron sword"] = 1, ["Iron helmet"] = 1 } })
48 local at = field()
49 test.move(p, at)
50 world.spawn(test.kind("Pilferling"), at + vector.create(3, 0, 0))
51 test.wait(6)
52 test.same(world.has(p, "Iron sword"), 1, "the sword's still there")
53 test.same(world.has(p, "Iron helmet"), 1, "and the helmet")
54end)
55
56test.case("none on Peaceful, and they're gone by day", function()
57 test.danger("peaceful")
58 test.daytime(0)
59 local p = test.player("Ada", { survival = true, carrying = { Cobblestone = 10 } })
60 local at = field()
61 test.move(p, at)
62 test.wait(20)
63 test.same(#pilferlings(), 0, "none on Peaceful")
64 test.danger("normal")
65 world.spawn(test.kind("Pilferling"), at + vector.create(8, 0, 0))
66 test.daytime(0.4)
67 test.wait(1)
68 test.same(#pilferlings(), 0, "gone by day")
69end)