Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MONITOR_NAME = "front"
- local REACTOR_NAME = "back"
- local monitor = peripheral.wrap(MONITOR_NAME)
- local reactor = peripheral.wrap(REACTOR_NAME)
- local DMST = "monitor"
- local mClick = DMST.."_click"
- local mTouch = DMST.."_touch"
- local mResize = DMST.."_resize"
- local MONITOR_COLORTABLE = {colors.lightBlue, colors.green, colors.red, colors.lightGray, colors.gray, colors.white}
- --lightblue = cryotheum, green = ender, red = redstone, lightgray = air, gray = casing, white = rod
- --local REACTOR_BLOCKTYPES = {"cryotheum", "ender", "redstone", "air", "casing", "rod"}
- local rSizeX,rSizeY,rSizeZ = 0
- local lastEnergyLevel = 0
- local lastCheck = os.clock()
- local c = "casing"
- local e = "ender"
- local r = "rod"
- local ROW1 = {c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c}
- local ROW2 = {c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c}
- local ROW3 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW4 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW5 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW6 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW7 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW8 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW9 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW10 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW11 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW12 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW13 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW14 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW15 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW16 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW17 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW18 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW19 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW20 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW21 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW22 = {c,c,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,r,r,e,e,c,c}
- local ROW23 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW24 = {c,c,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,c,c}
- local ROW25 = {c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c}
- local ROW26 = {c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c}
- local PIX = {ROW1,ROW2,ROW3,ROW4,ROW5,ROW6,ROW7,ROW8,ROW9,ROW10,ROW11,ROW12,ROW13,ROW14,ROW15,ROW16,ROW17,ROW18,ROW19,ROW20,ROW21,ROW22,ROW23,ROW24,ROW25,ROW26}
- local MODE_BOX_X,MODE_BOX_Y,MODE_BOX_WIDTH,MODE_BOX_HEIGHT = 1,27,24,3
- local INFO_BOX_X,INFO_BOX_Y,INFO_BOX_WIDTH,INFO_BOX_HEIGHT = 5,27,24,3
- local STOP_BOX_X,STOP_BOX_Y,STOP_BOX_WIDTH,STOP_BOX_HEIGHT = 24,27,24,3
- local currentScreen = ""
- local AUTO = true
- function init()
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.red)
- monitor.clear()
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.red)
- end
- function check()
- --TODO?
- end
- function getTemperature()
- --local temp = reactor.getTemperature()
- --local tempString = temp..""
- --if(string.len(tostring(temp))>3)then
- -- tempString = math.floor(temp/1000).."K "
- --end
- return reactor.getTemperature().."°C"
- end
- function getEnergyLevel()
- return reactor.getEnergyStored().."RF"
- end
- function getEnergyUsage()
- local currentEnergyLevel = reactor.getEnergyStored()
- local currentEnergyUsage = currentEnergyLevel - lastEnergyLevel
- local currentTimeDiff = os.clock()-lastCheck
- currentEnergyUsage = currentEnergyUsage / currentTimeDiff
- lastEnergyLevel = currentEnergyLevel
- lastCheck = os.clock()
- return currentEnergyUsage.." RF/s"
- end
- function getReactorState()
- return reactor.getActive()
- end
- function trimEnergy(l)
- --TODO?
- end
- function handleReactor()
- while true do
- if AUTO then
- if (reactor.getEnergyStored()>=8000000) then
- reactor.setActive(false)
- else
- reactor.setActive(true)
- end
- end
- os.sleep(2)
- end
- end
- function showReactor()
- for i=1,26,1 do
- for j=1,26,1 do
- local entry = PIX[i][j]
- if entry==c then
- monitor.setBackgroundColor(MONITOR_COLORTABLE[5])
- monitor.setCursorPos(i,j)
- monitor.write(" ")
- elseif entry==e then
- monitor.setBackgroundColor(MONITOR_COLORTABLE[2])
- monitor.setCursorPos(i,j)
- monitor.write(" ")
- elseif entry==r then
- monitor.setBackgroundColor(MONITOR_COLORTABLE[6])
- monitor.setCursorPos(i,j)
- monitor.write(" ")
- end
- end
- end
- end
- function fuckMyLife(j)
- monitor.setBackgroundColor(colors.lightGray)
- if j==4 then
- monitor.setBackgroundColor(colors.black)
- elseif j==8 then
- monitor.setBackgroundColor(colors.black)
- elseif j>=12 then
- if j<=23 then
- monitor.setBackgroundColor(colors.black)
- end
- end
- end
- function showSelection()
- for j=1,26,1 do
- for i=27,50,1 do
- monitor.setTextColor(colors.red)
- --fuckMyLife(j)
- monitor.setCursorPos(i,j)
- if j==2 then
- monitor.write("MODE")
- i = i+string.len("MODE")
- for i=i,26,1 do
- monitor.write(" ")
- end
- elseif i==6 then
- monitor.write("INFO")
- i = i+string.len("INFO")
- for i=i,26,1 do
- monitor.write(" ")
- end
- elseif j==25 then
- monitor.write("STOP")
- i = i+string.len("STOP")
- for i=i,26,1 do
- monitor.write(" ")
- end
- else
- monitor.write(" ")
- end
- end
- end
- currentScreen = "selection"
- end
- function stop()
- os.shutdown()
- end
- function showModes()
- for j=1,26,1 do
- for i=27,50,1 do
- fuckMyLife(j)
- monitor.setCursorPos(i,j)
- if j==2 then
- monitor.write("AUTO")
- i = i+string.len("AUTO")
- for i=i,26,1 do
- monitor.write(" ")
- end
- elseif j==6 then
- monitor.write("MANU")
- i = i+string.len("MANU")
- for i=i,26,1 do
- monitor.write(" ")
- end
- elseif j==25 then
- monitor.write("BACK")
- i = i+string.len("BACK")
- for i=i,26,1 do
- monitor.write(" ")
- end
- else
- monitor.write(" ")
- end
- end
- end
- currentScreen = "mode"
- end
- function showInfo()
- end
- function inFirstBox()
- if posX>=MODE_BOX_X then
- if posX<=MODE_BOX_X+MODE_BOX_HEIGHT-1 then
- if posY>=MODE_BOX_Y then
- if posY<=MODE_BOX_Y+MODE_BOX_WIDTH-1 then
- return true
- end
- end
- end
- end
- return false
- end
- function inSecondBox()
- if posX>=INFO_BOX_X then
- if posX<=INFO_BOX_X+INFO_BOX_HEIGHT-1 then
- if posY>=INFO_BOX_Y then
- if posY<=INFO_BOX_Y+INFO_BOX_WIDTH-1 then
- return true
- end
- end
- end
- end
- return false
- end
- function inLastBox()
- if posX>=STOP_BOX_X then
- if posX<=STOP_BOX_X+STOP_BOX_HEIGHT-1 then
- if posY>=STOP_BOX_Y then
- if posY<=STOP_BOX_Y+STOP_BOX_WIDTH-1 then
- return true
- end
- end
- end
- end
- return false
- end
- function XlistenForEvent()
- local event,button,posX,posY = os.pullEvent()
- if event==mTouch then
- if currentScreen=="selection" then
- if inFirstBox() then
- showModes()
- elseif inSecondBox() then
- showInfo()
- elseif inLastBox() then
- stop()
- end
- elseif currentScreen=="mode" then
- if inFirstBox() then
- AUTO = true
- elseif inSecondBox() then
- AUTO = false
- elseif inLastBox() then
- showSelection()
- end
- elseif currentScreen=="info" then
- end
- end
- end
- init()
- print("Successfully initialized!")
- showReactor()
- print("Reactor shown")
- showSelection()
- print("Selection shown")
- monitor.setCursorPos(1,5)
- monitor.write("X")
- while true do
- parallel.waitForAll(handleReactor,XlistenForEvent)
- os.sleep(.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement