Skip to content

Instantly share code, notes, and snippets.

@bananasov
Created July 10, 2022 13:50
Show Gist options
  • Save bananasov/fb24a391ba31fc6822180a96ae7634a7 to your computer and use it in GitHub Desktop.
Save bananasov/fb24a391ba31fc6822180a96ae7634a7 to your computer and use it in GitHub Desktop.
Bee keeping 👍
local config = require("config")
local bee_locations = config.bee_locations
local GuiH = require("GuiH")
local monitor = peripheral.find("monitor")
local gui = GuiH.new(monitor)
gui.debug = true
local watermarkText = gui.new.text{
text = gui.text{
x=1, y=1, height=1,
centered = true,
text = "Bee Keeping",
fg = colors.yellow
}
}
local beeTexts = {}
for i, location in pairs(bee_locations) do
beeTexts[i] = gui.new.text{
text = gui.text{
x=1, y=i+2, height=1,
text = "Beehive " .. tostring(i),
fg = colors.white
}
}
end
gui.async(function()
-- bee state stuff
while true do
for i, loc in pairs(bee_locations) do
local beeText = beeTexts[i]
local info = commands.getBlockInfo(loc.loc[1], loc.loc[2], loc.loc[3])
local honey_level = info.state and info.state.honey_level or 0
local readyText = (honey_level == 5 and "Ready to extract") or "Waiting for honey.."
beeText.text.text = ("Beehive %d: %d (%s)"):format(i, honey_level, readyText)
end
os.sleep(0.5)
end
end)
gui.execute()
-- just add your cords to `bee_locations` and done, the `id` field doesnt get used to it doesnt matter really. Thought it was needed but it wasn't.
-- If the location is NOT a bee hive or bee nest the honey level will always show as `0`.
return {
bee_locations = {
{id=1, loc={185, -60, 236}},
{id=2, loc={185, -59, 236}},
{id=3, loc={185, -58, 236}},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment