-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfurnace-status.lua
44 lines (36 loc) · 1.1 KB
/
furnace-status.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local modem = peripheral.find("modem") or error("No modem attached", 0)
local monitor = peripheral.find("monitor")
local speaker = peripheral.find("speaker")
monitor.setTextScale(0.5)
monitor.clear()
monitor.setCursorPos(4,1)
monitor.write("Furnace 1")
monitor.setCursorPos(4,2)
monitor.write("Fill Lvl")
monitor.setCursorPos(6,3)
monitor.write("loading")
while true do
if modem.isOpen(11) then
sleep(5)
local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
monitor.clear()
monitor.setCursorPos(4,1)
monitor.write("Furnace 1")
monitor.setCursorPos(4,2)
monitor.write("Fill Lvl")
if message == 15.0 then
monitor.setBackgroundColor(colors.green)
elseif message == 10.0 then
monitor.setBackgroundColor(colors.yellow)
elseif message == 5.0 then
monitor.setBackgroundColor(colors.orange)
elseif message == 0.0 then
monitor.setBackgroundColor(colors.red)
speaker.playNote("bell", 3, 6)
end
monitor.setCursorPos(6,3)
monitor.write(message)
else
modem.open(11)
end
end