Sign in
creature

Hedgehog

by Potluck · version 1 · Checked for all ages

Hedgehogs snuffle about the hill, and come trotting after anyone holding carrots. Their body is a Blockbench model: open hedgehog.bbmodel in Blockbench to change it.

1--!strict
2-- Hedgehog: a creature with no code of its own. Its body is a Blockbench
3-- model (hedgehog.bbmodel, made in Blockbench: open it there to change it),
4-- and its behaviors do the rest.
5
6local world = require("@potluck/world@0.11")
7local tweak = require("@potluck/tweak")
8
9local knobs = tweak {
10 count = { 3, min = 0, max = 8, label = "Hedgehogs", order = 1 },
11 spines = { "#5b4532", label = "Spines", order = 2 },
12}
13
14-- world.model reads the model into the same list of boxes a body is, so
15-- it can be changed before it's used: here, the spines take the knob's color
16local body = world.model("hedgehog.bbmodel")
17for _, part in body do
18 if string.find(part[1], "spines") then
19 part.color = knobs.spines
20 end
21end
22
23world.creature {
24 name = "Hedgehog",
25 speed = 1.4,
26 count = math.floor(knobs.count),
27 home = "start",
28 body = body,
29 behaviors = {
30 follow_food = "Carrots",
31 flee_when_hit = 5,
32 chatter = { "Snuffle.", "Hff hff.", "Snrrk." },
33 sound = "snuffle",
34 },
35}