Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local com = peripheral.wrap("back")
- local display = peripheral.wrap("right")
- local tanks = {
- coolantA1 = "rcirontankvalvetile_2",
- coolantB1 = "rcirontankvalvetile_3",
- coolantS = "rcirontankvalvetile_4",
- distilledA1 = "rcirontankvalvetile_5",
- distilledB1 = "rcirontankvalvetile_1",
- distilledS = "rcirontankvalvetile_6"
- }
- function tryTankLevel(tank)
- return com.callRemote(tank, "getTankInfo")[1].contents.amount
- end
- function getTankLevel(tank)
- local empty, level = pcall(tryTankLevel, tank)
- if (not empty) then
- return 0
- else
- return level
- end
- end
- local colorValue = 0
- function toggleColor(color)
- if (rs.testBundledInput("bottom", color)) then
- rs.setBundledOutput("bottom", colorValue - color)
- colorValue = colorValue - color
- else
- rs.setBundledOutput("bottom", colorValue + color)
- colorValue = colorValue + color
- end
- end
- function printAtMonitor(x, y, color, text)
- display.setTextColor(color)
- display.setCursorPos(x, y)
- display.write(text)
- end
- function printAt(x,y,color,text)
- term.setTextColor(color)
- term.setCursorPos(x, y)
- term.write(text)
- end
- function signalToColor(signal)
- if (signal) then
- return colors.lime
- else
- return colors.red
- end
- end
- function reactorDisplay()
- local run = true
- while true do
- local coolant = {
- tankA1 = getTankLevel(tanks.coolantA1),
- tankB1 = getTankLevel(tanks.coolantB1),
- tankA2 = 0,
- tankB2 = 0,
- tankA3 = 0,
- tankB3 = 0,
- tankA4 = 0,
- tankB4 = 0,
- tankS = getTankLevel(tanks.coolantS),
- SA1 = rs.testBundledInput("top", 1),
- A1A2 = rs.testBundledInput("top", 2),
- A2A3 = rs.testBundledInput("top", 4),
- A3A4 = rs.testBundledInput("top", 8),
- A4S = rs.testBundledInput("top", 16),
- SB1 = rs.testBundledInput("top", 32),
- B1B2 = rs.testBundledInput("top", 64),
- B2B3 = rs.testBundledInput("top", 128),
- B3B4 = rs.testBundledInput("top", 256),
- B4S = rs.testBundledInput("top", 512)
- }
- local distilled = {
- tankA1 = getTankLevel(tanks.distilledA1),
- tankB1 = getTankLevel(tanks.distilledB1),
- tankA2 = 0,
- tankB2 = 0,
- tankA3 = 0,
- tankB3 = 0,
- tankA4 = 0,
- tankB4 = 0,
- tankS = getTankLevel(tanks.distilledS),
- SA1 = rs.testBundledInput("bottom", 1),
- A1A2 = rs.testBundledInput("bottom", 2),
- A2A3 = rs.testBundledInput("bottom", 4),
- A3A4 = rs.testBundledInput("bottom", 8),
- A4S = rs.testBundledInput("bottom", 16),
- SB1 = rs.testBundledInput("bottom", 32),
- B1B2 = rs.testBundledInput("bottom", 64),
- B2B3 = rs.testBundledInput("bottom", 128),
- B3B4 = rs.testBundledInput("bottom", 256),
- B4S = rs.testBundledInput("bottom", 512)
- }
- display.clear()
- printAtMonitor(1,1,colors.white,"Coolant:")
- printAtMonitor(2,2,colors.cyan, "S: "..coolant.tankS)
- printAtMonitor(2,4,colors.cyan, "1A: "..coolant.tankA1)
- printAtMonitor(2,5,colors.cyan, "1B: "..coolant.tankB1)
- printAtMonitor(2,6,colors.cyan, "2A: "..coolant.tankA2)
- printAtMonitor(2,7,colors.cyan, "2B: "..coolant.tankB2)
- printAtMonitor(2,8,colors.cyan, "3A: "..coolant.tankA3)
- printAtMonitor(2,9,colors.cyan, "3B: "..coolant.tankB3)
- printAtMonitor(2,10,colors.cyan, "4A: "..coolant.tankA4)
- printAtMonitor(2,11,colors.cyan, "4B: "..coolant.tankB4)
- printAtMonitor(1,2,signalToColor(coolant.SA1), "v")
- printAtMonitor(1,3,signalToColor(coolant.SB1), "v")
- printAtMonitor(1,4,signalToColor(coolant.A1A2), "v")
- printAtMonitor(1,5,signalToColor(coolant.B1B2), "v")
- printAtMonitor(1,6,signalToColor(coolant.A2A3), "v")
- printAtMonitor(1,7,signalToColor(coolant.B2B3), "v")
- printAtMonitor(1,8,signalToColor(coolant.A3A4), "v")
- printAtMonitor(1,9,signalToColor(coolant.B3B4), "v")
- printAtMonitor(1,10,signalToColor(coolant.A4S), "^")
- printAtMonitor(1,11,signalToColor(coolant.B4S), "^")
- printAtMonitor(14,1,colors.white,"Distilled:")
- printAtMonitor(15,2,colors.lightBlue, "S: "..distilled.tankS)
- printAtMonitor(15,4,colors.lightBlue, "1A: "..distilled.tankA1)
- printAtMonitor(15,5,colors.lightBlue, "1B: "..distilled.tankB1)
- printAtMonitor(15,6,colors.lightBlue, "2A: "..distilled.tankA2)
- printAtMonitor(15,7,colors.lightBlue, "2B: "..distilled.tankB2)
- printAtMonitor(15,8,colors.lightBlue, "3A: "..distilled.tankA3)
- printAtMonitor(15,9,colors.lightBlue, "3B: "..distilled.tankB3)
- printAtMonitor(15,10,colors.lightBlue, "4A: "..distilled.tankA4)
- printAtMonitor(15,11,colors.lightBlue, "4B: "..distilled.tankB4)
- printAtMonitor(14,2,signalToColor(distilled.SA1), "v")
- printAtMonitor(14,3,signalToColor(distilled.SB1), "v")
- printAtMonitor(14,4,signalToColor(distilled.A1A2), "v")
- printAtMonitor(14,5,signalToColor(distilled.B1B2), "v")
- printAtMonitor(14,6,signalToColor(distilled.A2A3), "v")
- printAtMonitor(14,7,signalToColor(distilled.B2B3), "v")
- printAtMonitor(14,8,signalToColor(distilled.A3A4), "v")
- printAtMonitor(14,9,signalToColor(distilled.B3B4), "v")
- printAtMonitor(14,10,signalToColor(distilled.A4S), "^")
- printAtMonitor(14,11,signalToColor(distilled.B4S), "^")
- if (run) then
- printAtMonitor(1,12, colors.white, "Running")
- end
- run = not run
- sleep(1)
- end
- end
- function transferLiquid(start, target)
- local output2 = 0
- local output10 = 0
- while (not start == target) do
- output2 = output2 + 10^start
- output10 = output10 + 2^start
- start = start + 1
- end
- if (string.sub(""..output2,1,5) == "11111") then
- output10 = output10 -31
- end
- if (string.sub(""..output2,6,10) == "11111")then
- output10 = output10 -992
- end
- return output10
- end
- function selectPump()
- local line = 1
- while true do
- local pumps = {"S ","1A","2A","3A","4A","1B","2B","3B","4B"}
- for i=1,9 do
- term.setCursorPos(2,i + 1)
- term.clearLine()
- printAt(2, i + 1, colors.white, pumps[i])
- end
- printAt(1,line+1,colors.white,"[")
- printAt(4,line+1,colors.white,"]")
- local event, key = os.pullEvent("key")
- if (key == 200) then
- line = line -1
- if (line == 0) then
- line = 1
- end
- end
- if (key == 208) then
- line = line + 1
- if (line == 10) then
- line = 9
- end
- end
- if (key == 28) then
- if (line > 5) then
- return line + 1
- else
- return line
- end
- end
- end
- end
- function selection()
- local pumps = {"S ","1A","2A","3A","4A","S ","1B","2B","3B","4B"}
- local coolant = {
- start = 0,
- target = 0,
- on = false
- }
- local distilled = {
- start = 0,
- target = 0,
- on = false
- }
- local cursor = {0,0}
- while (true) do
- term.clear()
- printAt(1,1,colors.white,"Coolant "..pumps[coolant.start + 1].."->"..pumps[coolant.target + 1].." ")
- printAt(1,2,colors.white,"Distilled "..pumps[distilled.start + 1].."->"..pumps[distilled.target + 1].." ")
- if (cursor[1]==0) then
- printAt(10,1+cursor[2],colors.white,"[")
- printAt(17,1+cursor[2],colors.white,"]")
- else
- printAt(17,1+cursor[2],colors.white,"[")
- printAt(21,1+cursor[2],colors.white,"]")
- end
- if (coolant.on) then
- printAt(18,1,colors.green,"On")
- else
- printAt(18,1,colors.red,"Off")
- end
- if (distilled.on) then
- printAt(18,2,colors.green,"On")
- else
- printAt(18,2,colors.red,"Off")
- end
- local event, key = os.pullEvent("key")
- if (key == 203) then
- cursor[1] = 0
- end
- if (key == 205) then
- cursor[1] = 1
- end
- if (key == 200) then
- cursor[2] = 0
- end
- if (key == 208) then
- cursor[2] = 1
- end
- if (key == 28) then
- if (cursor[1] == 0) then
- if (cursor[2] == 0) then
- term.clear()
- printAt(1,1, colors.white, "Coolant: ->")
- coolant.start = selectPump() - 1
- printAt(10,1, colors.white, pumps[coolant.start + 1])
- coolant.target = selectPump() - 1
- else
- printAt(1,1, colors.white, "Distilled: ->")
- distilled.start = selectPump() - 1
- printAt(12,1, colors.white, pumps[distilled.start + 1])
- distilled.target = selectPump() - 1
- end
- else
- if (cursor[2] == 0) then
- coolant.on = not coolant.on
- else
- distilled.on = not distilled.on
- end
- end
- if (coolant.on) then
- rs.setBundledOutput("top", transferLiquid(coolant.start, coolant.target))
- else
- rs.setBundledOutput("top", 0)
- end
- if (distilled.on) then
- rs.setBundledOutput("bottom", transferLiquid(distilled.start, distilled.target))
- else
- rs.setBundledOutput("bottom", 0)
- end
- end
- end
- end
- parallel.waitForAny(reactorDisplay, selection)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement