Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local network = peripheral.wrap("back")
- local cr = "redrouter_3" -- control router
- local resources = {}
- resources.logs = "redrouter_0"
- resources.apples = "redrouter_2"
- resources.sticks = "redrouter_1"
- local old = term
- local monitor = peripheral.wrap("left")
- term.redirect(monitor)
- term.clear()
- term.setCursorPos(1,1)
- term.write("starting..")
- os.sleep(1.5)
- term.clear()
- local threshold = 80 --percentage
- function on()
- network.callRemote(cr, "setOutput", "back", true)
- end
- function off()
- network.callRemote(cr, "setOutput", "back", false)
- end
- function get_percent_from_redstone(amount)
- return amount / 15
- end
- repeat
- term.clear()
- local stay_on = false
- for name, resource in pairs(resources) do
- percent = get_percent_from_redstone(network.callRemote(resource, "getAnalogInput", "front")) * 100
- term.write(name..": "..math.floor(percent).."%")
- x, y = term.getCursorPos()
- term.setCursorPos(1,y+1)
- if percent < threshold then
- stay_on = true
- end
- end
- if stay_on then
- on()
- else
- off()
- end
- os.sleep(1)
- term.setCursorPos(1,1)
- until redstone.getInput("top")
- network.callRemote(cr, "setOutput", "back", false)
Add Comment
Please, Sign In to add comment