Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------
- --required function libs
- --------------------------
- local os = require("os")
- local computer = require("computer")
- local term = require("term")
- local colors = require("colors")
- local filesystem = require("filesystem")
- local component = require("component")
- local keyboard = require("keyboard")
- local event = require("event")
- local gpu = component.gpu
- local redstone = component.redstone
- local gpu1 = component.gpu -- get the proxy of the primary GPU
- local addr1 = tostring(component.get("c9d9")) -- the address of the first screen
- local addr2 = tostring(component.get("fb45")) -- the address of the second screen
- local touchLocation = ""
- local touchName = ""
- local touchX = 0
- local touchY = 0
- local meItems = component.me_controller.getItemsInNetwork()
- local meFluids = component.me_controller.getFluidsInNetwork()
- local tempColor = colors_magenta
- local availableMobsListPage = 1
- colors_white = 0xffffff
- colors_orange = 0xff6600
- colors_magenta = 0xff00ff
- colors_lightblue = 0x0099ff
- colors_yellow = 0xffff00
- colors_lime = 0x00ff00
- colors_pink = 0xff3399
- colors_gray = 0x737373
- colors_silver = 0xc0c0c0
- colors_cyan = 0x169c9d
- colors_purple = 0x8932b7
- colors_blue = 0x3c44a9
- colors_brown = 0x825432
- colors_green = 0x5d7c15
- colors_red = 0xb02e26
- colors_black = 0x000000
- mobs = ""
- lightToggle1 = false
- lightToggle2 = false
- lightToggle3 = false
- lightToggle4 = false
- lightToggle5 = false
- navigateMobsListSelected = 1
- temp15 = 0
- term.clear()
- function isRedstoneChannelOpen(redstoneChannel)
- local redstoneChannelData = redstone.getBundledInput(5, redstoneChannel)
- if redstoneChannelData > 0 then
- return true
- else return false
- end
- end
- function openRedstoneChannel(redstoneChannel)
- local redstoneChannelData = redstone.setBundledOutput(5, redstoneChannel, 255)
- end
- function closeRedstoneChannel(redstoneChannel)
- local redstoneChannelData = redstone.setBundledOutput(5, redstoneChannel, 0)
- end
- function isPlayerInCorridor ()
- local temp1 = isRedstoneChannelOpen(1)
- if temp1 then
- return true
- else return false
- end
- end
- -----------------------------
- ------ functions for UI -----
- ------------\/---------------
- function drawLine (posX, posY, length, highth, line_color)
- gpu.setBackground(line_color)
- gpu.fill(posX, posY, length, highth, " ")
- end
- function drawLight1(X, Y, length, hight)
- if lightToggle1 == true then
- drawText(X-1, Y-2, "enabled", colors_blue, colors_white)
- drawLine(X, Y, length, hight, colors_green)
- else
- drawText(X-1, Y-2, "disabled", colors_red, colors_white)
- drawLine(X, Y, length, hight, colors_red)
- end
- end
- function drawLight2(X, Y, length, hight)
- if lightToggle2 == true then
- drawText(X-1, Y-2, "enabled", colors_green, colors_white)
- drawLine(X, Y, length, hight, colors_green)
- else
- drawText(X-1, Y-2, "disabled", colors_red, colors_white)
- drawLine(X, Y, length, hight, colors_red)
- end
- end
- function drawText (X, Y, text, color_txt, color_bg)
- term.setCursor(X, Y)
- gpu.setBackground(color_bg)
- gpu.setForeground(color_txt, false)
- term.write(tostring(text))
- gpu.setBackground(colors_black)
- end
- function drawButton (label, x, y, hight, func, fuc_data, txt_color, bttn_color, enabled)
- length = #label+2
- if not enabled then
- drawLine(x, y, length, hight, colors_gray)
- drawText(x, y, label, colors_gray, colors_gray)
- end
- if enabled then
- drawLine(x, y, length, hight, bttn_color)
- drawText(x+1,y+hight/2, label, txt_color, bttn_color)
- if touchX ~= nil or touchY ~= nil then
- if (touchX >= x) and (touchX <= x + length-1) and (touchY >= y) and (touchY <= y + hight-1) then
- func(fuc_data)
- end
- end
- end
- end
- function drawInvisibleButton (x, y, hight, length, func)
- if touchX ~= nil or touchY ~= nil then
- if (touchX >= x) and (touchX <= x + length) and (touchY >= y) and (touchY <= y + hight) then
- func()
- end
- end
- end
- function swichToScreen1()
- gpu.bind(addr1)
- end
- function swichToScreen2()
- gpu.bind(addr2)
- end
- function clearBothScreens()
- swichToScreen1()
- term.clear()
- swichToScreen2()
- term.clear()
- swichToScreen1()
- end
- function clearPrimaryScreen()
- swichToScreen1()
- gpu.setResolution(160, 50)
- term.clear()
- end
- function clearSecondaryScreen()
- swichToScreen2()
- gpu.setResolution(140, 50)
- term.clear()
- end
- function drawCorridorAccessPanel()
- local panelX = 3
- local panelY = 10
- local panelSizeX = 14
- local panelSizeY = 13
- local buttonSizeY = 5
- drawLine(panelX-1, panelY, panelSizeX+2, panelSizeY, colors_gray)
- drawText(panelX-1, panelY-1, "corridor access", colors_white, colors_gray)
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawButton("open door ", panelX+1, panelY+1, buttonSizeY, openCoridorDoor, _, colors_lightblue, colors_green, true)
- drawButton("close door", panelX+1, panelY+buttonSizeY+2, buttonSizeY, closeCoridorDoor, _, colors_lightblue, colors_red, true)
- end
- function drawRoomAccessPanel()
- local panelX = 100
- local panelY = 10
- local panelSizeX = 14
- local panelSizeY = 13
- local buttonSizeY = 5
- drawLine(panelX-1, panelY, panelSizeX+2, panelSizeY, colors_gray)
- drawText(panelX-1, panelY-1, "room access", colors_white, colors_gray)
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawButton("open door ", panelX+1, panelY+1, buttonSizeY, openCoridorDoor, _, colors_lightblue, colors_green, true)
- drawButton("close door", panelX+1, panelY+buttonSizeY+2, buttonSizeY, closeCoridorDoor, _, colors_lightblue, colors_red, true)
- end
- function drawStorageInfoPanel()
- local panelX = 80
- local panelY = 5
- local panelSizeX = 55
- local panelSizeY = 5
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+1, panelY+1, "current stored essence:", colors_lightblue, colors_gray)
- drawText(110, panelY+1, getCurrentEssenceInStorage().." mili-Buckets", colors_lightblue, colors_gray)
- drawText(panelX+1, panelY+3, "number of available mobs ", colors_lightblue, colors_gray)
- drawText(panelX+30, panelY+3, numberOfMobsInSystem, colors_lightblue, colors_gray)
- end
- function drawAvailableMobsListPanel()
- local panelX = 80
- local panelY = 11
- local panelSizeX = 26
- local panelSizeY = 9
- numberOfMobsInSystem = #meItems
- if availableMobsListPage == 1 then
- if navigateMobsListSelected == 1 then
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+6, panelY, "available mobs", colors_white, colors_gray)
- drawText(panelX+1, panelY+1, meItems[1]["entity"], colors_lime, colors_silver)
- drawText(panelX+1, panelY+2, meItems[2]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+3, meItems[3]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+4, meItems[4]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+5, meItems[5]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+6, meItems[6]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+7, "NONE", colors_lime, colors_gray)
- elseif navigateMobsListSelected == 2 then
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+6, panelY, "available mobs", colors_white, colors_gray)
- drawText(panelX+1, panelY+1, meItems[1]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+2, meItems[2]["entity"], colors_lime, colors_silver)
- drawText(panelX+1, panelY+3, meItems[3]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+4, meItems[4]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+5, meItems[5]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+6, meItems[6]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+7, "NONE", colors_lime, colors_gray)
- elseif navigateMobsListSelected == 3 then
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+6, panelY, "available mobs", colors_white, colors_gray)
- drawText(panelX+1, panelY+1, meItems[1]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+2, meItems[2]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+3, meItems[3]["entity"], colors_lime, colors_silver)
- drawText(panelX+1, panelY+4, meItems[4]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+5, meItems[5]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+6, meItems[6]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+7, "NONE", colors_lime, colors_gray)
- elseif navigateMobsListSelected == 4 then
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+6, panelY, "available mobs", colors_white, colors_gray)
- drawText(panelX+1, panelY+1, meItems[1]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+2, meItems[2]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+3, meItems[3]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+4, meItems[4]["entity"], colors_lime, colors_silver)
- drawText(panelX+1, panelY+5, meItems[5]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+6, meItems[6]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+7, "NONE", colors_lime, colors_gray)
- elseif navigateMobsListSelected == 5 then
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+6, panelY, "available mobs", colors_white, colors_gray)
- drawText(panelX+1, panelY+1, meItems[1]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+2, meItems[2]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+3, meItems[3]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+4, meItems[4]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+5, meItems[5]["entity"], colors_lime, colors_silver)
- drawText(panelX+1, panelY+6, meItems[6]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+7, "NONE", colors_lime, colors_gray)
- elseif navigateMobsListSelected == 6 then
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+6, panelY, "available mobs", colors_white, colors_gray)
- drawText(panelX+1, panelY+1, meItems[1]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+2, meItems[2]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+3, meItems[3]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+4, meItems[4]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+5, meItems[5]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+6, meItems[6]["entity"], colors_lime, colors_silver)
- drawText(panelX+1, panelY+7, "NONE", colors_lime, colors_gray)
- elseif navigateMobsListSelected == 7 then
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawText(panelX+6, panelY, "available mobs", colors_white, colors_gray)
- drawText(panelX+1, panelY+1, meItems[1]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+2, meItems[2]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+3, meItems[3]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+4, meItems[4]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+5, meItems[5]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+6, meItems[6]["entity"], colors_lime, colors_gray)
- drawText(panelX+1, panelY+7, "NONE", colors_lime, colors_silver)
- end
- drawButton("DN", panelX-5, panelY+5, 3, navigateMobSelection_DN, _, colors_orange, colors_lime, true)
- drawButton("UP", panelX-5, panelY+1, 3, navigateMobSelection_UP, _, colors_orange, colors_lime, true)
- end
- end
- function drawMobSpawnerInfoPanel()
- local panelX = 111
- local panelY = 11
- local panelSizeX = 24
- local panelSizeY = 5
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_silver)
- if navigateMobsListSelected <7 then
- drawText(panelX+1, panelY+1, meItems[navigateMobsListSelected]["entity"], colors_magenta, colors_silver)
- elseif navigateMobsListSelected == 7 then
- drawText(panelX+1, panelY+1, "NONE", colors_magenta, colors_silver)
- end
- end
- function drawMobSpawnerControlPanel ()
- local panelX = 74
- local panelY = 4
- local panelSizeX = 62
- local panelSizeY = 40
- drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_white)
- drawStorageInfoPanel()
- drawAvailableMobsListPanel()
- drawMobSpawnerInfoPanel()
- drawMobSpawnerControls()
- drawMobCrusherIndicatorLights()
- drawMobSpawnerIndicatorLights()
- end
- function drawMobCrusherIndicatorLights()
- local panelX = 80
- local panelY = 20
- local panelSizeX = 55
- local panelSizeY = 10
- --drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawLine(panelX+1, panelY+1, 10, 7, colors_white)
- drawLight1(panelX+3, panelY+3, 6, 2)
- drawText(panelX+3, panelY+6, "crusher", colors_black, colors_white)
- drawText(panelX+3, panelY+7, "control", colors_black, colors_white)
- end
- function drawMobSpawnerIndicatorLights()
- local panelX = 90
- local panelY = 20
- local panelSizeX = 55
- local panelSizeY = 10
- --drawLine(panelX, panelY, panelSizeX, panelSizeY, colors_gray)
- drawLine(panelX+1, panelY+1, 10, 7, colors_white)
- drawLight2(panelX+3, panelY+3, 6, 2)
- drawText(panelX+3, panelY+6, "spawner", colors_black, colors_white)
- drawText(panelX+3, panelY+7, "control", colors_black, colors_white)
- end
- function drawMobSpawnerControls ()
- local panelX = 81
- local panelY = 37
- local panelSizeX = 58
- local panelSizeY = 16
- drawButton("crushers", panelX+1, panelY+1, 3, toggleCrusher, _, colors_cyan, colors_green, true)
- drawButton("spawner", panelX+12, panelY+1, 3, toggleSpawner, _, colors_cyan, colors_green, true)
- drawButton("tttt", panelX+30, panelY-19, 3,toggleSpawner , _, colors_magenta, colors_green, true)
- end
- function drawUIForScreen2()
- drawCorridorAccessPanel()
- end
- function drawUIForScreen1()
- drawCorridorAccessPanel()
- drawMobSpawnerControlPanel ()
- end
- function touchCheck()
- touchLocation,touchName, touchX, touchY = event.pull(0.01, "touch")
- end
- -------------/\--------------
- ------ functions for UI -----
- -----------------------------
- ----------------------------
- --- functions for buttons --
- -------------\/-------------
- function toggleCrusher()
- if not isRedstoneChannelOpen(2) then
- lightToggle1 = true
- openRedstoneChannel(2)
- else
- lightToggle1 = false
- closeRedstoneChannel(2)
- end
- end
- function toggleSpawner()
- if isRedstoneChannelOpen(7) then
- lightToggle2 = false
- closeRedstoneChannel(7)
- else
- lightToggle2 = true
- openRedstoneChannel(7)
- end
- end
- function navigateMobSelection_DN()
- if navigateMobsListSelected <8 then
- navigateMobsListSelected = navigateMobsListSelected +1
- end
- if navigateMobsListSelected ==8 then
- navigateMobsListSelected = 1
- end
- end
- function navigateMobSelection_UP()
- if navigateMobsListSelected >0 then
- navigateMobsListSelected = navigateMobsListSelected -1
- end
- if navigateMobsListSelected ==0 then
- navigateMobsListSelected = 7
- end
- end
- function openCoridorDoor()
- openRedstoneChannel(0)
- end
- function closeCoridorDoor()
- closeRedstoneChannel(0)
- end
- function closeAllRedstoneChannels()
- closeRedstoneChannel(0)
- closeRedstoneChannel(1)
- closeRedstoneChannel(2)
- closeRedstoneChannel(3)
- closeRedstoneChannel(4)
- closeRedstoneChannel(5)
- closeRedstoneChannel(6)
- closeRedstoneChannel(7)
- closeRedstoneChannel(8)
- closeRedstoneChannel(9)
- closeRedstoneChannel(10)
- closeRedstoneChannel(11)
- closeRedstoneChannel(12)
- closeRedstoneChannel(13)
- closeRedstoneChannel(14)
- closeRedstoneChannel(15)
- end
- function getCurrentEssenceInStorage()
- if meFluids[1] == nil then
- return "0"
- else
- return meFluids[1]["amount"]
- end
- end
- ------------/\--------------
- --- functions for buttons --
- ----------------------------
- clearBothScreens()
- closeAllRedstoneChannels()
- while true do
- touchCheck() -- returns x and y coords of cursor when screen is clicked
- swichToScreen1() -- swiches to primary screen
- drawUIForScreen1() -- draws UI for primary screen
- if isPlayerInCorridor () then -- if player is in coridor then
- touchCheck() -- returns x and y coords of cursor when screen is clicked
- swichToScreen2() -- swiches to secondary screen
- drawUIForScreen2() -- draws UI for secondary screen
- else
- clearSecondaryScreen()
- swichToScreen1() -- swiches to primary screen
- end
- drawText(1, 1, tostring(navigateMobsListSelected), colors_cyan, colors_black)
- os.sleep(0.0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement