Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("monitor_0")
- tank = peripheral.wrap("bottom")
- sp = peripheral.wrap("right")
- alarm = 0
- message = false
- ack = false
- while true do
- GS = tank.getStoredGas()
- GM = tank.getMaxGas()
- GP = (GS/GM) * 100
- mon.setCursorPos(1,1)
- mon.setTextScale(5)
- message = false
- if redstone.getInput("left") == true then
- ack = true
- end
- if GP < 25 then
- if alarm == 0 then
- alarm = 1
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.black)
- message = false
- elseif alarm == 1 then
- alarm = 2
- out = "LOW"
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.red)
- message = true
- elseif alarm == 2 then
- alarm = 3
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.black)
- message = false
- elseif alarm == 3 then
- alarm = 0
- out = "GAS"
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.red)
- message = true
- end
- if ack == false then
- sp.playNote("bell",3,0)
- end
- elseif GP < 50 then
- mon.setTextColor(colors.red)
- mon.setBackgroundColor(colors.black)
- ack = false
- message = false
- os.sleep(4)
- elseif GP == 100 then
- mon.setBackgroundColor(colors.green)
- mon.setTextColor(colours.white)
- ack = false
- message = true
- out = "100%"
- os.sleep(14)
- elseif GP > 75 then
- mon.setBackgroundColor(colors.green)
- mon.setTextColor(colors.white)
- ack = false
- message = false
- os.sleep(14)
- else
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.black)
- ack = false
- message = false
- os.sleep(9)
- end
- mon.clear()
- if message == false then
- out = math.ceil(GP)
- out = (string.sub(out, -2).."%")
- if (string.len(out)) == 3 then
- out = (" "..out)
- elseif (string.len(out)) == 2 then
- out = (" "..out)
- end
- end
- mon.write(out)
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement