Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Global variables
- IsOnFlag = true
- mouseWidth = 0
- mouseHeight = 0
- ColorMix = 0
- ------------------
- --initialize
- monitor = peripheral.wrap("top")
- monitor.clear()
- monitor.setCursorPos(1,1)
- reactor = peripheral.wrap("back")
- --Write On/Off button
- function WriteButtons(IsOn)
- monitor.setTextColor(colors.white)
- if IsOn == true then
- monitor.setBackgroundColour((colours.lime))
- monitor.setCursorPos(24,2)
- monitor.write(" ")
- monitor.setCursorPos(24,3)
- monitor.write(" ON ")
- monitor.setCursorPos(24,4)
- monitor.write(" ")
- else
- monitor.setBackgroundColour((colours.red))
- monitor.setCursorPos(24,2)
- monitor.write(" ")
- monitor.setCursorPos(24,3)
- monitor.write(" OFF ")
- monitor.setCursorPos(24,4)
- monitor.write(" ")
- end
- monitor.setBackgroundColour((colours.black))
- end
- --Check mouse to button click
- function checkClickPosition()
- if mouseWidth >= 24 and mouseWidth <= 28 and mouseHeight >= 2 and mouseHeight <= 4 then
- if IsOnFlag == true then
- IsOnFlag = false
- else
- IsOnFlag = true
- end
- WriteButtons(IsOnFlag)
- UpdateSensors()
- end
- end
- --
- function DrawTextLine(State, Color, Line, TextH, TextOk, TextFail)
- monitor.setCursorPos(1,Line)
- monitor.setTextColor(colors.white)
- monitor.write(TextH)
- monitor.setCursorPos(14,Line)
- monitor.setTextColor(Color)
- if State then
- monitor.write(TextOk)
- else
- monitor.write(TextFail)
- end
- end
- --
- function DrawValueLine(value, Color, Line, TextH)
- monitor.setCursorPos(1,Line)
- monitor.setTextColor(colors.white)
- monitor.write(TextH)
- monitor.setCursorPos(14,Line)
- monitor.setTextColor(Color)
- val = math.floor(value)
- monitor.write(val)
- end
- --draw data from redstone channels (sensors)
- function UpdateSensors()
- monitor.setBackgroundColor(colours.black)
- S_Status = reactor.getActive()
- EnergyLevel = reactor.getEnergyStored()
- PowerPercent = (EnergyLevel / 10000000) * 100
- PowerPercent = math.floor(PowerPercent)
- --RodsLevel = PowerPercent
- RodsLevel = 100
- ProduceLevel = reactor.getEnergyProducedLastTick()
- ProducePercent = math.floor((ProduceLevel / 3960) * 100)
- Coolant = reactor.getCoolantAmount()
- HotFluid = reactor.getHotFluidAmount()
- if Coolant < 1000 then
- RodsLevel = 100
- elseif HotFluid > 9000 then
- RodsLevel = 100
- else
- RodsLevel = 110 - math.floor(Coolant / 98)
- end
- if RodsLevel < 0 then
- RodsLevel = 0
- end
- DrawTextLine(S_Status , colors.green , 1, "STATUS:" , " ON " , " OFF ")
- --DrawValueLine(PowerPercent, colors.red, 2, "ENERGY:")
- --DrawValueLine(ProducePercent, colors.blue, 3, "POWER:")
- DrawValueLine(100-RodsLevel, colors.yellow, 2, "RODS: ")
- DrawValueLine(Coolant, colors.white, 3, "COOL: ")
- DrawValueLine(HotFluid, colors.white, 4, "HOT: ")
- reactor.setAllControlRodLevels(RodsLevel)
- if IsOnFlag then
- reactor.setActive(true)
- else
- reactor.setActive(false)
- end
- WriteButtons(IsOnFlag)
- end
- w,h=monitor.getSize()
- print(w)
- print(h)
- checkClickPosition()
- WriteButtons(false)
- UpdateSensors()
- repeat
- local myTimer = os.startTimer(0.25)
- event,p1,p2,p3 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2 -- sets mouseWidth
- mouseHeight = p3 -- and mouseHeight
- checkClickPosition() -- this runs our function
- end
- if event=="timer" then
- UpdateSensors()
- end
- until event=="char" and p1==("q")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement