Sign in
creature

Bees

by Potluck · version 1 · Checked for all ages

Bees buzz from flower to flower on the Green. Put down a beehive (a workbench makes one from planks and hay) near flowers, and bees come to live in it and fill it with honey: use a full hive to take two jars of honey. Leave them be: bop a bee in survival and it stings.

1--!strict
2local test = require("@potluck/test@0.6")
3local world = require("@potluck/world@0.20")
4
5local function ground(x: number, z: number): vector
6 return vector.create(x, world.top(x, z) + 1, z)
7end
8
9local function bees(): { number }
10 return world.creatures(test.kind("Bee"))
11end
12
13-- a hive with flowers around it, put down by a player in creative
14local function garden(p): vector
15 local x, z = p.position.x + 4, p.position.z
16 local hive = ground(x, z)
17 test.place(p, hive, "Beehive")
18 for i, d in { { 3, 0 }, { -3, 1 }, { 0, 3 }, { 1, -3 }, { 3, 3 } } do
19 local f = ground(x + d[1], z + d[2])
20 if world.block(f) == "Air" then
21 test.place(p, f, if i % 2 == 0 then "Red flower" else "Violet flower")
22 end
23 end
24 return hive
25end
26
27test.case("a hive brings two more bees", function()
28 local p = test.player("Ada")
29 test.wait(1)
30 test.same(#bees(), 4, "bees on the Green")
31 garden(p)
32 test.wait(1)
33 test.same(#bees(), 6, "two more for the hive")
34end)
35
36test.case("bees fill a hive with honey, and a full one gives two jars", function()
37 local p = test.player("Ada")
38 local hive = garden(p)
39 test.wait(240)
40 test.same(world.block(hive), "Full beehive", "full of honey")
41 local s = test.player("Bo", { survival = true })
42 test.use_block(s, hive)
43 test.same(world.has(s, "Honey"), 2, "two jars")
44 test.same(world.block(hive), "Beehive", "empty again")
45end)
46
47test.case("a broken full hive gives a hive back, and is forgotten", function()
48 local p = test.player("Ada", { survival = true })
49 local x, z = p.position.x + 3, p.position.z
50 local at = ground(x, z)
51 world.set_block(at, "Full beehive")
52 test.dig(p, at)
53 test.same(world.has(p, "Beehive"), 1, "a hive back")
54 test.same(world.has(p, "Full beehive"), 0, "not a full one")
55end)
56
57test.case("a bopped bee stings in survival", function()
58 local p = test.player("Ada", { survival = true })
59 test.wait(1)
60 local b = test.creature(bees()[1])
61 test.hit(p, b)
62 test.wait(0.2)
63 test.same(test.health(p), 19, "stung")
64end)