Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------
- -- Railcraft Steam Turbine Monitor v1.0
- ----------------------------------------------------------------
- -- Written by AmigaLink (http://www.youtube.com/user/AmigaLink)
- ----------------------------------------------------------------
- mon = peripheral.wrap("monitor_9")
- mfsu = peripheral.wrap("chargepad.mfsu_4")
- rednet.open("right")
- scale = .5
- --
- function writeLeft(text)
- local x,y = mon.getCursorPos()
- x = math.floor((monWidth /3 - string.len(text))/2 )
- -- mon.clearLine()
- mon.setCursorPos(x+1,y)
- mon.write(text)
- end
- function writeCenter(text)
- local x,y = mon.getCursorPos()
- x = math.floor(((monWidth /3 -string.len(text))/2)+(monWidth /3))
- -- mon.clearLine()
- mon.setCursorPos(x+1,y)
- mon.write(text)
- end
- function newLine(lines)
- if lines == nil then lines = 1 end
- local x,y = mon.getCursorPos()
- mon.setCursorPos(1,y+lines)
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.clear()
- mon.setTextScale(scale)
- monWidth, monHeight = mon.getSize()
- --print(monWidth)
- mon.setCursorPos(1,2)
- writeLeft("Steam Turbine Monitor")
- writeCenter("MFSU Charge Monitor")
- newLine()
- writeLeft("-----------------------")
- writeCenter("-----------------------")
- while true do
- peripherals = peripheral.getNames()
- mon.setCursorPos(1,3)
- turbines = 0
- for i,p in ipairs(peripherals) do
- if peripheral.getType(p) == "rcsteamturbinetile" then
- turbines = turbines + 1
- if turbines > 1 then
- mon.setTextColor(colors.gray)
- newLine("2")
- for i = 1,monWidth do
- -- mon.write("_")
- end
- mon.setTextColor(colors.white)
- end
- TurbineOutput = peripheral.call(p, "getTurbineOutput")
- RotorStatus = peripheral.call(p, "getTurbineRotorStatus")
- newLine("2")
- writeLeft("Output: " .. math.floor(TurbineOutput + 0.5) * 2 .. " EU")
- newLine("2")
- if RotorStatus == nil then
- mon.setTextColor(colors.red)
- RotorStatus = 0
- writeLeft("No rotor available!")
- mon.setTextColor(colors.white)
- else
- writeLeft("Rotor Status: " .. RotorStatus .. " %")
- end
- newLine("2")
- mon.write(" ")
- x,y = mon.getCursorPos()
- barLenght = math.floor((monWidth - 2)/3)
- barWidth = (barLenght / 100) * RotorStatus
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.gray)
- for i = 1,barLenght do
- mon.write("|")
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.write(" ")
- mon.setCursorPos(x,y)
- if RotorStatus < 41 then
- barColor = colors.red
- elseif RotorStatus > 40 and RotorStatus < 51 then
- barColor = colors.orange
- elseif RotorStatus > 50 and RotorStatus < 61 then
- barColor = colors.yellow
- elseif RotorStatus > 60 and RotorStatus < 81 then
- barColor = colors.lime
- else
- barColor = colors.green
- end
- mon.setBackgroundColor(barColor)
- mon.setTextColor(colors.black)
- for i = 1,barWidth do
- mon.write("|")
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- end
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement