Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local br = peripheral.wrap("back")
- local m = peripheral.wrap("bottom")
- br.setActive(true)
- function power()
- m.setCursorPos(2,10)
- m.write("Power: ")
- m.setCursorPos(9,10)
- local active = " ON "
- if br.getActive() then
- m.setBackgroundColor(colors.green)
- else
- active = " OFF "
- m.setBackgroundColor(colors.red)
- end
- m.write(active)
- m.setBackgroundColor(colors.black)
- end
- function control()
- m.setCursorPos(2,13)
- m.write("Rods: ")
- m.setCursorPos(9,13)
- m.setBackgroundColor(colors.green)
- m.write(" +1% ")
- m.setCursorPos(9,15)
- m.write(" +5% ")
- m.setCursorPos(9,17)
- m.write(" +10%")
- m.setBackgroundColor(colors.red)
- m.setCursorPos(15,13)
- m.write(" -1% ")
- m.setCursorPos(15,15)
- m.write(" -5% ")
- m.setCursorPos(15,17)
- m.write(" -10%")
- m.setBackgroundColor(colors.black)
- end
- function update_display()
- m.setTextColor(colors.white)
- m.setBackgroundColor(colors.black)
- m.clear()
- m.setCursorPos(2,2)
- rf = br.getEnergyProducedLastTick()/1000
- mb = br.getFuelConsumedLastTick()
- m.write(rf.." KiRF/t")
- m.setCursorPos(2,4)
- m.write(mb.." mB/t")
- m.setCursorPos(2,6)
- m.write("Control Rods: "..br.getControlRodLevel(1).."%")
- power()
- control()
- end
- while true do
- os.startTimer(1)
- local event,s,x,y = os.pullEvent()
- if event == "timer" then
- local stored = br.getEnergyStored()/100000
- print(stored)
- if stored < 45 then
- local run = true
- local count = 0
- while run do
- if count == 0 then
- local current = br.getControlRodLevel(1)
- br.setAllControlRodLevels(current-1)
- count = 6
- end
- sleep(1)
- local new = br.getEnergyStored()/100000
- if new > 50 then
- run = false
- end
- count = count - 1
- end
- elseif stored > 55 then
- local run = true
- local count = 0
- while run do
- if count == 0 then
- local current = br.getControlRodLevel(1)
- br.setAllControlRodLevels(current+1)
- count = 31
- end
- sleep(1)
- local new = br.getEnergyStored()/100000
- if new < 50 then
- run = false
- end
- count = count - 1
- end
- end
- update_display()
- elseif event == "monitor_touch" then
- local level = br.getControlRodLevel(1)
- if x >= 9 and x <= 13 then
- if y == 10 then
- br.setActive(not br.getActive())
- elseif y == 13 then
- br.setAllControlRodLevels(level+1)
- elseif y == 15 then
- br.setAllControlRodLevels(level+5)
- elseif y == 17 then
- br.setAllControlRodLevels(level+10)
- end
- elseif x >= 15 and x <= 19 then
- if y == 13 then
- br.setAllControlRodLevels(level-1)
- elseif y == 15 then
- br.setAllControlRodLevels(level-5)
- elseif y == 17 then
- br.setAllControlRodLevels(level-10)
- end
- end
- update_display()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement