A boat for every wood, made at a workbench (under Travel) from five planks. Use one on water to set it afloat, then Interact to climb in and steer it with your movement: it rides the top of the water, calm and level, with nothing to make you seasick. Bop an empty boat to pick it back up. Boats stay where you leave them.
| 1 | --!strict |
| 2 | -- Boats' own tests: `potluck-server --test=boats`. |
| 3 | local test = require("@potluck/test@0.9") |
| 4 | local world = require("@potluck/world@0.35") |
| 5 | |
| 6 | -- a stone basin of water high in the sky, away from the Green, `depth` |
| 7 | -- deep: the middle of its floor |
| 8 | local 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 = -12, 12 do |
| 12 | for dz = -12, 12 do |
| 13 | local edge = math.abs(dx) == 12 or math.abs(dz) == 12 |
| 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) |
| 22 | end |
| 23 | |
| 24 | local function boats(wood: string): { number } |
| 25 | return world.creatures(test.kind(wood .. " boat")) |
| 26 | end |
| 27 | |
| 28 | test.case("a boat set on the water floats at the top, still, and is picked up again", function() |
| 29 | local p = test.player("Ada", { survival = true, carrying = { ["Pine boat"] = 1 } }) |
| 30 | local floor = pool(5) |
| 31 | test.move(p, floor + vector.create(0, 6, 0)) |
| 32 | test.hold(p, "Pine boat") |
| 33 | test.use_block(p, floor + vector.create(0, 3, 0)) |
| 34 | test.wait(0.5) |
| 35 | test.same(#boats("Pine"), 1, "afloat") |
| 36 | test.same(world.has(p, "Pine boat"), 0, "it left her pockets") |
| 37 | test.wait(6) |
| 38 | local b = test.creature(boats("Pine")[1]) |
| 39 | local top = floor.y + 5 |
| 40 | test.check(math.abs(b.position.y - (top - 0.36)) < 0.1, "at the top of the water, not " .. b.position.y) |
| 41 | local y1 = b.position.y |
| 42 | test.wait(2) |
| 43 | test.check(math.abs(test.creature(boats("Pine")[1]).position.y - y1) < 0.02, "and not bobbing") |
| 44 | test.move(p, b.position + vector.create(1.5, 0, 0)) |
| 45 | test.hit(p, b) |
| 46 | test.wait(0.3) |
| 47 | test.same(#boats("Pine"), 0, "picked up") |
| 48 | test.same(world.has(p, "Pine boat"), 1, "and back in her pockets") |
| 49 | end) |
| 50 | |
| 51 | test.case("ridden, a boat carries its rider at the top of the water", function() |
| 52 | local p = test.player("Ada") |
| 53 | local floor = pool(4) |
| 54 | test.move(p, floor + vector.create(0, 5, 0)) |
| 55 | test.hold(p, "Oak boat") |
| 56 | test.use_block(p, floor + vector.create(0, 2, 0)) |
| 57 | test.wait(3) |
| 58 | local b = test.creature(boats("Oak")[1]) |
| 59 | test.move(p, b.position + vector.create(1.5, 0, 0)) |
| 60 | test.ride(p, b) |
| 61 | test.check(b.rider ~= nil, "aboard") |
| 62 | test.wait(4) |
| 63 | test.check(math.abs(b.position.y - (floor.y + 4 - 0.36)) < 0.15, "still at the top") |
| 64 | end) |
| 65 | |
| 66 | test.case("boats stay out of the dry", function() |
| 67 | local p = test.player("Ada") |
| 68 | test.hold(p, "Oak boat") |
| 69 | local g = world.spot("green") |
| 70 | test.use_block(p, vector.create(g.x, world.top(g.x, g.z), g.z)) |
| 71 | test.wait(0.3) |
| 72 | test.same(#boats("Oak"), 0, "no boat on land") |
| 73 | end) |