Blocks of fired clay: red bricks, terracotta (the game's own, from the badlands), roof tiles, clay slabs and paper lanterns, made in a kiln. Each block is drawn in letters in potluck.toml, so change a color or a row there and the world shows it.
| 1 | --!strict |
| 2 | -- Brickworks' own tests: `potluck-server --test=brickworks`. |
| 3 | |
| 4 | local test = require("@potluck/test@0.2") |
| 5 | local world = require("@potluck/world@0.12") |
| 6 | |
| 7 | -- a survival player beside a kiln they've put down |
| 8 | local function kiln(carrying: { [string]: number }): (any, vector) |
| 9 | carrying.Kiln = 1 |
| 10 | local p = test.player("Ada", { survival = true, carrying = carrying }) |
| 11 | local x, z = p.position.x + 2, p.position.z |
| 12 | local at = vector.create(x, world.top(x, z) + 1, z) |
| 13 | test.place(p, at, "Kiln") |
| 14 | return p, at |
| 15 | end |
| 16 | |
| 17 | test.case("its blocks are in the world, by name", function() |
| 18 | for _, name in { "Red bricks", "Terracotta", "Roof tiles", "Clay slab", "Paper lantern", "Kiln" } do |
| 19 | test.check(pcall(world.kind, name), name) |
| 20 | end |
| 21 | test.same(world.kind("Red bricks"), "hard", "kind, from potluck.toml") |
| 22 | local p = test.player("Bo") |
| 23 | local x, z = p.position.x + 3, p.position.z |
| 24 | local at = vector.create(x, world.top(x, z) + 1, z) |
| 25 | world.set_block(at, "Roof tiles") |
| 26 | test.same(world.block(at), "Roof tiles") |
| 27 | end) |
| 28 | |
| 29 | test.case("the kiln fires dirt into bricks", function() |
| 30 | local p, at = kiln({ Dirt = 9, Sand = 1 }) |
| 31 | test.same(world.block(at), "Kiln") |
| 32 | test.use_block(p, at) |
| 33 | local q = test.asked(p) |
| 34 | test.same(q.choices[1], "4 Red bricks for 4 Dirt") |
| 35 | test.answer(p, 1) |
| 36 | test.same(world.has(p, "Red bricks"), 4) |
| 37 | test.same(world.has(p, "Dirt"), 5) |
| 38 | q = test.asked(p) |
| 39 | test.check(string.find(q.text, "Fired 4 Red bricks", 1, true) ~= nil, q.text) |
| 40 | -- one sand isn't enough for glass |
| 41 | test.answer(p, 5) |
| 42 | q = test.asked(p) |
| 43 | test.check(string.find(q.text, "You'll need 2 Sand", 1, true) ~= nil, q.text) |
| 44 | test.same(world.has(p, "Sand"), 1, "nothing taken") |
| 45 | end) |
| 46 | |
| 47 | test.case("in creative, it says what it's for", function() |
| 48 | local p = test.player("Cy") |
| 49 | local x, z = p.position.x + 2, p.position.z |
| 50 | local at = vector.create(x, world.top(x, z) + 1, z) |
| 51 | world.set_block(at, "Kiln") |
| 52 | test.use_block(p, at) |
| 53 | local q = test.asked(p) |
| 54 | test.check(q ~= nil and string.find(q.text, "In survival", 1, true) ~= nil, "a word on what it does") |
| 55 | end) |