Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("monitor_0")
- os.loadAPI("touchpoint")
- t = touchpoint.new("monitor_0")
- rea = peripheral.wrap("right")
- monX, monY = mon.getSize()
- --Clear Function
- function clear()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- --Draw Line Function
- function drawLine(x,y, length, size, color_bar)
- for yPos = y, y+size-1 do
- mon.setBackgroundColor(color_bar)
- mon.setCursorPos(x, yPos)
- mon.write(string.rep(" ", length))
- end
- end
- --Progress Bar Function
- function drawProg(x, y, length, size, minVal, maxVal, color_bar, color_bg)
- drawLine(x, y, length, size, color_bg)
- local barSize = math.floor((minVal/maxVal)*length)
- drawLine(x, y, barSize, size, color_bar)
- end
- --Function for Centering Titles
- function centerText(title, y, per, value, maxValue)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- local txtX, txtY = mon.getSize()
- if per == true then
- mon.setCursorPos((txtX+string.len(title))/2-(string.len(title)), y)
- mon.write(title..':'..math.floor((value/maxValue)*100).."%")
- else
- mon.setCursorPos((txtX+string.len(title))/2-(string.len(title)-1), y)
- mon.write(title)
- end
- end
- --Control Rod 1
- t:add("A-10", R11, 2, 9, 5, 9)
- t:add("A-5", R12, 7, 9, 9, 9)
- t:add("A-1", R13, 11, 9, 13, 9)
- t:add("A+1", R14, 70, 9, 72, 9)
- t:add("A+5", R15, 74, 9, 76, 9)
- t:add("A+10", R16, 78, 9, 81, 9)
- --Control Rod 2
- t:add("B-10", R21, 2, 11, 5, 11)
- t:add("B-5", R22, 7, 11, 9, 11)
- t:add("B-1", R23, 11, 11, 13, 11)
- t:add("B+1", R24, 70, 11, 72, 11)
- t:add("B+5", R25, 74, 11, 76, 11)
- t:add("B+10", R26, 78, 11, 81, 11)
- --Control Rod 3
- t:add("C-10", R31, 2, 13, 5, 13)
- t:add("C-5", R32, 7, 13, 9, 13)
- t:add("C-1", R33, 11, 13, 13, 13)
- t:add("C+1", R34, 70, 13, 72, 13)
- t:add("C+5", R35, 74, 13, 76, 13)
- t:add("C+10", R36, 78, 13, 81, 13)
- --Control Rod 4
- t:add("D-10", R41, 2, 15, 5, 15)
- t:add("D-5", R42, 7, 15, 9, 15)
- t:add("D-1", R43, 11, 15, 13, 15)
- t:add("D+1", R44, 70, 15, 72, 15)
- t:add("D+5", R45, 74, 15, 76, 15)
- t:add("D+10", R46, 78, 15, 81, 15)
- --Control Rod 5
- t:add("E-10", R51, 2, 17, 5, 17)
- t:add("E-5", R52, 7, 17, 9, 17)
- t:add("E-1", R53, 11, 17, 13, 17)
- t:add("E+1", R54, 70, 17, 72, 17)
- t:add("E+5", R55, 74, 17, 76, 17)
- t:add("E+10", R56, 78, 17, 81, 17)
- --Additional buttons
- t:add("On/Off", OnOff, 1, 1, 6, 1)
- t:add("X", stopProgram, 82, 1, 82, 1)
- --Button Functions
- --Control Rod 1
- function R11()
- rea.setControlRodLevel(1, rea.getControlRodLevel(1)-10)
- end
- function R12()
- rea.setControlRodLevel(1, rea.getControlRodLevel(1)-5)
- end
- function R13()
- rea.setControlRodLevel(1, rea.getControlRodLevel(1)-1)
- end
- function R14()
- rea.setControlRodLevel(1, rea.getControlRodLevel(1)+10)
- end
- function R15()
- rea.setControlRodLevel(1, rea.getControlRodLevel(1)+5)
- end
- function R16()
- rea.setControlRodLevel(1, rea.getControlRodLevel(1)+1)
- end
- --Control Rod 2
- function R21()
- rea.setControlRodLevel(2, rea.getControlRodLevel(2)-10)
- end
- function R22()
- rea.setControlRodLevel(2, rea.getControlRodLevel(2)-5)
- end
- function R23()
- rea.setControlRodLevel(2, rea.getControlRodLevel(2)-1)
- end
- function R24()
- rea.setControlRodLevel(2, rea.getControlRodLevel(2)+1)
- end
- function R25()
- rea.setControlRodLevel(2, rea.getControlRodLevel(2)+5)
- end
- function R26()
- rea.setControlRodLevel(2, rea.getControlRodLevel(2)+10)
- end
- --Control Rod 3
- function R31()
- rea.setControlRodLevel(3, rea.getControlRodLevel(3)-10)
- end
- function R32()
- rea.setControlRodLevel(3, rea.getControlRodLevel(3)-5)
- end
- function R33()
- rea.setControlRodLevel(3, rea.getControlRodLevel(3)-1)
- end
- function R34()
- rea.setControlRodLevel(3, rea.getControlRodLevel(3)+1)
- end
- function R35()
- rea.setControlRodLevel(3, rea.getControlRodLevel(3)+5)
- end
- function R36()
- rea.setControlRodLevel(3, rea.getControlRodLevel(3)+10)
- end
- --Control Rod 4
- function R41()
- rea.setControlRodLevel(4, rea.getControlRodLevel(4)-10)
- end
- function R42()
- rea.setControlRodLevel(4, rea.getControlRodLevel(4)-5)
- end
- function R43()
- rea.setControlRodLevel(4, rea.getControlRodLevel(4)-1)
- end
- function R44()
- rea.setControlRodLevel(4, rea.getControlRodLevel(4)+1)
- end
- function R45()
- rea.setControlRodLevel(4, rea.getControlRodLevel(4)+5)
- end
- function R46()
- rea.setControlRodLevel(4, rea.getControlRodLevel(4)+10)
- end
- --Control Rod 5
- function R51()
- rea.setControlRodLevel(5, rea.getControlRodLevel(5)-10)
- end
- function R52()
- rea.setControlRodLevel(5, rea.getControlRodLevel(5)-5)
- end
- function R53()
- rea.setControlRodLevel(5, rea.getControlRodLevel(5)-1)
- end
- function R54()
- rea.setControlRodLevel(5, rea.getControlRodLevel(5)+1)
- end
- function R55()
- rea.setControlRodLevel(5, rea.getControlRodLevel(5)+5)
- end
- function R56()
- rea.setControlRodLevel(5, rea.getControlRodLevel(5)+10)
- end
- --Other buttons
- function OnOff()
- if rea.getActive == true then
- rea.setActive(false)
- else
- rea.setActive(true)
- end
- end
- function stopProgram()
- SD = true
- end
- --Progress bar updates and control rod control
- local SD = false
- while SD == false do
- t:draw
- --Main Title
- centerText("A.R.C.S.", 1, false, 0, 0)
- --Power Bar
- centerText("energy Stored", 4, true, rea.getEnergyStored(), 10000000)
- drawProg(14, 5, 54, 1, rea.getEnergyStored(), 10000000, colors.green, colors.red)
- --Stored Fuel
- centerText('Fuel Stored', 6, true, rea.getFuelAmount(), rea.getFuelAmountMax())
- drawProg(14, 7, 54, 1, rea.getFuelAmount(), rea.getFuelAmountMax(), colors.green, colors.red)
- --Control Rod 1
- centerText('Control Rod 1 Insertion', 8, true, rea.getControlRodLevel(0), 100)
- drawProg(14, 9, 54, 1, rea.getControlRodLevel(0), 100, colors.green, colors.red)
- --Control Rod 2
- centerText('Control Rod 2 Insertion', 10, true, rea.getControlRodLevel(1), 100)
- drawProg(14, 11, 54, 1, rea.getControlRodLevel(1), 100, colors.green, colors.red)
- --Control Rod 3
- centerText('Control Rod 3 Insertion', 12, true, rea.getControlRodLevel(2), 100)
- drawProg(14, 13, 54, 1, rea.getControlRodLevel(2), 100, colors.green, colors.red)
- --Control Rod 4
- centerText('Control Rod 4 Insertion', 14, true, rea.getControlRodLevel(3), 100)
- drawProg(14, 15, 54, 1, rea.getControlRodLevel(3), 100, colors.green, colors.red)
- --Control Rod 5
- centerText('Control Rod 5 Insertion', 16, true, rea.getControlRodLevel(4), 100)
- drawProg(14, 17, 54, 1, rea.getControlRodLevel(4), 100, colors.green, colors.red)
- --Other Things
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement