Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.unloadAPI("ProgressBar")
- os.loadAPI("ProgressBar")
- os.unloadAPI("button")
- os.loadAPI("button")
- button.setMon("top")
- function setbuttons()
- button.add("status", "On/Off","toggle",2,4,15,6,colors.red,colors.green,colors.white,function() prepMsg() end)
- button.setState("status",false)
- button.draw()
- end
- rednet.open("bottom")
- ProgressBar.SetPeripheral("top")
- m=peripheral.wrap("top")
- m.setTextScale(1)
- m.setTextColor(5)
- function split(str, delim, maxNb)
- if string.find(str, delim) == nil then
- return { str }
- end
- if maxNb == nil or maxNb <1 then
- maxNb = 0
- end
- local result = {}
- local pat = "(.-)"..delim.."()"
- local nb = 0
- local lastPos
- for part, pos in string.gmatch(str,pat) do
- nb = nb+1
- result[nb]=part
- lastPos=pos
- if nb==maxNb then break end
- end
- if nb ~= maxNb then
- result[nb+1] = string.sub(str,lastPos)
- end
- return result
- end
- function round(val, decimal)
- if (decimal) then
- return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
- else
- return math.floor(val+0.5)
- end
- end
- function writeAt(x,y,text)
- m.setCursorPos(x,y)
- m.write(text)
- end
- function prepMsg
- local coollvl = reactor.getCoolantAmount("")
- local coolmax = reactor.getCoolantAmountMax("")
- local coolpct = coollvl/coolmax
- msg="toggleActive"
- rednet.open("bottom")
- shell.run("clear")
- rednet.send(70,msg) -- Reactor Control Screen
- end
- while true do
- local time= os.time()
- local fTime = textutils.formatTime(time,false)
- local event, id, msg = os.pullEvent("rednet_message")
- local Tab = split(msg,"|",4)
- local pc = round(Tab[3]*100,0)
- local es = round(Tab[4]/100000,0)
- m.clear()
- setbuttons()
- writeAt(22,15,fTime)
- writeAt(2,2,"Reactor Info")
- writeAt(2,4,"Energy Stored")
- writeAt(2,6,"Fuel Level: ")
- writeAt(2,8,"Core Temp: "..round(Tab[2],1).."C")
- writeAt(2,10,"Status: "..Tab[1])
- ProgressBar.SetTable("Fuel",100,pc,20,45,6)
- ProgressBar.SetTable("Energy",100,es,20,45,4)
- ProgressBar.DrawToPeripheral()
- sleep(1)
- -- ProgressBar.SetCurValue("Test",pc)
- -- ProgressBar.DrawToPeripheral()
- -- sleep(1)
- button.check() -- This goes into a wait loop and does not come out again....
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement