Many-legged things that live in the dark of caves. Underground, away from any light, they come skittering at anyone in survival, climb up after you and nip. A torch or lantern keeps them off, so light your way. Bop one three times to pop it (a sword bops harder), and it leaves silk, which a workbench spins into wool or a bowstring. None come on a Peaceful world, and fewer on a Gentle one.
| 1 | --!strict |
| 2 | local test = require("@potluck/test@0.7") |
| 3 | local world = require("@potluck/world@0.21") |
| 4 | |
| 5 | local function crawlers(): { number } |
| 6 | return world.creatures(test.kind("Cave Crawler")) |
| 7 | end |
| 8 | |
| 9 | -- a dark room dug out well under where a player stands, with them in it |
| 10 | local function cave(p): vector |
| 11 | local x, z = math.floor(p.position.x), math.floor(p.position.z) |
| 12 | local y = world.top(x, z) - 16 |
| 13 | for dx = -9, 9 do |
| 14 | for dz = -9, 9 do |
| 15 | world.set_block(vector.create(x + dx, y - 1, z + dz), "Stone") |
| 16 | for dy = 0, 2 do |
| 17 | world.set_block(vector.create(x + dx, y + dy, z + dz), "Air") |
| 18 | end |
| 19 | world.set_block(vector.create(x + dx, y + 3, z + dz), "Stone") |
| 20 | end |
| 21 | test.wait(0) |
| 22 | end |
| 23 | return vector.create(x + 0.5, y, z + 0.5) |
| 24 | end |
| 25 | |
| 26 | test.case("crawlers come at you in a dark cave", function() |
| 27 | test.danger("normal") |
| 28 | local p = test.player("Ada", { survival = true }) |
| 29 | local at = cave(p) |
| 30 | test.move(p, at) |
| 31 | test.wait(10) |
| 32 | test.check(#crawlers() >= 2, "crawlers came out") |
| 33 | test.wait(10) |
| 34 | test.check(test.health(p) < 20, "and nipped") |
| 35 | end) |
| 36 | |
| 37 | test.case("a light keeps them off", function() |
| 38 | test.danger("normal") |
| 39 | local p = test.player("Ada", { survival = true }) |
| 40 | local at = cave(p) |
| 41 | world.set_block(at + vector.create(1, 0, 0), "Lantern") |
| 42 | test.move(p, at) |
| 43 | test.wait(12) |
| 44 | test.same(#crawlers(), 0, "none came") |
| 45 | end) |
| 46 | |
| 47 | test.case("none on a Peaceful world, and none for a player in creative", function() |
| 48 | test.danger("peaceful") |
| 49 | local p = test.player("Ada", { survival = true }) |
| 50 | local at = cave(p) |
| 51 | test.move(p, at) |
| 52 | test.wait(10) |
| 53 | test.same(#crawlers(), 0, "none on Peaceful") |
| 54 | test.danger("hard") |
| 55 | local c = test.player("Cy") |
| 56 | test.move(c, at) |
| 57 | test.move(p, at + vector.create(0, 40, 0)) |
| 58 | test.wait(10) |
| 59 | test.same(#crawlers(), 0, "none for Cy") |
| 60 | end) |
| 61 | |
| 62 | test.case("three bops pop one, and it leaves silk", function() |
| 63 | test.danger("normal") |
| 64 | local p = test.player("Ada", { survival = true }) |
| 65 | local at = cave(p) |
| 66 | test.move(p, at) |
| 67 | local id = world.spawn(test.kind("Cave Crawler"), at + vector.create(2, 0, 0)) |
| 68 | test.wait(0.2) |
| 69 | local c = test.creature(id) |
| 70 | test.hit(p, c) |
| 71 | test.hit(p, c) |
| 72 | test.check(test.creature(id) ~= nil, "still there after two") |
| 73 | test.hit(p, c) |
| 74 | test.same(test.creature(id), nil, "popped") |
| 75 | test.check(world.has(p, "Silk") >= 1, "silk") |
| 76 | end) |