Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setSupply()
- local RUNNING = true
- local DM = 0
- local strDM
- local SIDE = sensors.getController()
- local SENSOR = "Sensor"
- local INFO = sensors.getSensorInfo(SIDE, SENSOR, "probes")
- local MONITOR = peripheral.wrap("back")
- local probe, targets, t, target, d, i, v
- while RUNNING do
- DM = 0
- for probe in string.gmatch(INFO.probes, "%a+") do
- local targets = sensors.getAvailableTargetsforProbe(SIDE, SENSOR, probe);
- for t, target in pairs(targets) do
- local d = sensors.getSensorReadingAsDict(SIDE, SENSOR, target, probe);
- for i, v in pairs(d) do
- if tostring(i) == "TotalItems" then
- DM = DM + v
- end
- end
- end
- end
- strDM = tostring(DM)
- term.clear()
- term.setCursorPos(1, 1)
- print("Supply : " .. strDM)
- MONITOR.clear()
- MONITOR.setCursorPos(1, 2)
- MONITOR.write(" Supply")
- MONITOR.setCursorPos(1, 4)
- MONITOR.write(" ")
- if string.len(strDM) == 5 then
- MONITOR.write(" ")
- MONITOR.write(string.sub(strDM, 0, 2))
- MONITOR.write(".")
- MONITOR.write(string.sub(strDM, 3))
- elseif string.len(strDM) == 4 then
- MONITOR.write(string.sub(strDM, 0, 1))
- MONITOR.write(".")
- MONITOR.write(string.sub(strDM, 2))
- elseif string.len(strDM) == 3 then
- MONITOR.write(strDM)
- else
- MONITOR.write(tostring(DM))
- end
- sleep(5)
- end
- end
- function input()
- local RUNNING = true
- while RUNNING do
- local event, param1 = os.pullEvent("char")
- if param1 == "x" then
- return false
- end
- end
- return false
- end
- parallel.waitForAny(setSupply, input)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement