Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("bottom")
- mon.clear()
- function paintText(energy)
- if energy > 75 then
- mon.setTextColor(colors.green)
- elseif energy > 25 then
- mon.setTextColor(colors.yellow)
- else
- mon.setTextColor(colors.red)
- end
- end
- function resetColor()
- mon.setTextColor(colors.white)
- end
- if mon == nil then
- print("Monitor not found.")
- end
- function draw(info)
- print("Updating monitor...")
- local mon = peripheral.wrap("bottom")
- mon.clear()
- local w, h = mon.getSize()
- local x = 1
- local y = 1
- mon.setTextScale(1.5)
- mon.setCursorPos(x, y)
- mon.write("Energy: ")
- local ePercent = math.floor(info.energy*1000)/10
- mon.write( ePercent.."%")
- paintText(ePercent)
- mon.setCursorPos(x, y+1)
- local ePer = (info.energy) * 20
- mon.write( string.rep("#", math.floor(ePer) ) )
- mon.write( string.rep("-", 20 - math.floor(ePer)))
- resetColor()
- mon.setCursorPos(x, y+2)
- mon.write("Fuel: ")
- local fPercent = math.floor(info.fuel*1000)/10
- mon.write(fPercent.."%")
- paintText(fPercent)
- mon.setCursorPos(x, y+3)
- local fPer = (info.fuel) * 20
- mon.write( string.rep("#", math.floor(fPer)))
- mon.write( string.rep("-", 20 - math.floor(fPer)))
- resetColor()
- mon.setCursorPos(x, y+4)
- mon.write("RF/t: ")
- mon.write(info.rfptick)
- mon.setCursorPos(x, y+6)
- mon.write("Fuel/t: ")
- local fuelPerTick = math.floor(info.rfptick*10000)/10000
- mon.write(fuelPerTick)
- mon.setCursorPos(x,y+7)
- mon.write("Status: ")
- if(info.active) then
- mon.setTextColor(colors.green)
- mon.write("ONLINE")
- else
- mon.setTextColor(colors.red)
- mon.write("OFFLINE")
- end
- end
- function calcProgress(val, max)
- local per = val / max
- local progress = per * 14
- return progress
- end
- function getInfo()
- rednet.open("left")
- print("Waiting for Signal...")
- local id, msg, protocol = rednet.receive()
- if id == 4 then
- stats.fuel = msg
- elseif id == 16 then
- stats.active = msg.active
- stats.rfptick = msg.rfptick
- stats.rpm = msg.rpm
- elseif id == 17 then
- stats.energy = msg
- end
- if msg then
- print("Signal Found!")
- return msg
- else
- return false
- end
- end
- stats = {fuel = 0, active = false, rfptick = 0, rpm = 0, energy = 0}
- while true do
- getInfo()
- draw(stats)
- resetColor()
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement