Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------
- -- LPnet monitor program1.0
- --------setting-----------
- storageComputerID = 19
- maxStrageSize = 16
- reactorComputerID = 12
- fontColor = colors.white
- accentColor = colors.lightGray
- --------function-----------
- function accent(accx,accy,acccolor,accmes)
- if accx ~= 0 then mon.setCursorPos(accx,accy) end
- mon.setTextColor(acccolor)
- mon.write(accmes)
- end
- function message(x,y,infcolor,mes1,inf,mes2)
- if x ~= 0 then mon.setCursorPos(x,y) end
- mon.setTextColor(fontColor)
- mon.write(mes1)
- mon.setTextColor(infcolor)
- mon.write(inf)
- mon.setTextColor(fontColor)
- mon.write(mes2)
- end
- function gauge(x1,y1,x2,y2,color1,color2,value,maxValue)
- valuex = (x2-x1)*value/maxValue + x1
- for X = x1,x2 do
- for Y = y1,y2 do
- mon.setBackgroundColor(color2)
- mon.setCursorPos(X,Y)
- mon.write(" ")
- end
- end
- if value ~= 0 then
- for X = x1,valuex do
- for Y = y1,y2 do
- mon.setBackgroundColor(color1)
- mon.setCursorPos(X,Y)
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function timeInf()
- time = os.time()
- time_str = textutils.formatTime(time)
- if time > 6 and time < 18.5 then
- mon.setTextColor(colors.yellow)
- else
- mon.setTextColor(colors.blue)
- end
- mon.setCursorPos(1,1)
- mon.clearLine()
- mon.write(time_str)
- end
- -----------main--------------------
- for k, v in pairs(peripheral.getNames()) do
- if string.find(peripheral.getType(v),"Logi") == 1 then
- LP = peripheral.wrap(v)
- end
- end
- mon = peripheral.find("monitor")
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setTextScale(0.5)
- while true do
- timeInf()
- state = {}
- state[1],state[2],state[3] = os.pullEvent("LP_MESSAGE")
- if state[2] == storageComputerID then
- mon.setCursorPos(2,2)
- mon.clearLine()
- accent(2,2,accentColor,"Storage")
- if state[3] < 0 then
- accent(0,2,colors.cyan," waiting turtle")
- else
- LC = (state[3]-math.floor(state[3]))*1000
- filledLC = math.floor(state[3])/1000
- if filledLC/LC > 0.8 then
- message(0,2,colors.red," : ",string.format("%d",filledLC),"/")
- else
- message(0,2,colors.lime," : ",string.format("%d",filledLC),"/")
- end
- message(0,0,colors.white,"",string.format("%d",LC),"LC")
- gauge(20,2,30,2,colors.lime,colors.gray,filledLC,LC)
- end
- end
- if state[2] == reactorComputerID then
- accent(2,4,accentColor,"Reactor")
- message(0,4,colors.lime," : ",string.format("%d",state[3]),"RF/Tick")
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement