Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- API = require("buttonAPI")
- local component = require("component")
- local sides = require("sides")
- local event = require("event")
- local keyboard = require("keyboard")
- local gpu = component.gpu
- local colors = {
- blue = 0x4286F4,
- purple = 0xB673d6,
- red = 0xC14141,
- green = 0xDA841,
- black = 0x000000,
- white = 0xFFFFFF,
- gray = 0x47494C,
- lightGray = 0xBBBBBB
- }
- local sections = {
- buttons = { x = 1, y = 1, width = 50, height = 20, title = " CONTROLS "},
- position = { x = 53, y = 1, width = 26, height = 20, title = " POSITION "}
- }
- -- List floor (components)
- local floors = {
- main = "c88",
- first = "495",
- second = "425"
- }
- local screens = {
- main = "180",
- first = "380",
- second = "39b"
- }
- local floorComponents = {}
- local elevatorPosition = nil
- function moveTo(floor)
- floorComponents[floor].setOutput(sides.east, 15)
- floorComponents[floor].setOutput(sides.east, 0)
- elevatorPosition = floor
- end
- function moveToMain()
- moveTo(floors.main)
- end
- function moveToFirst()
- moveTo(floors.first)
- end
- local maxWidth, maxHeight = component.gpu.maxResolution()
- function clear()
- gpu.fill(1, 1, maxWidth, maxHeight, " ")
- end
- function setButtons()
- for k,v in pairs(screens) do
- gpu.bind(component.get(v))
- API.screen()
- API.setTable(k, moveToMain, 0, 0, 10, 10, "Call", {on = colors.green, off = colors.green})
- end
- -- Set the first screen as default again
- gpu.bind(component.get(screens.main))
- end
- function printBorders(sectionName)
- local s = sections[sectionName]
- -- set border
- gpu.setBackground(colors.gray)
- gpu.fill(s.x, s.y, s.width, 1, " ")
- gpu.fill(s.x, s.y, 1, s.height, " ")
- gpu.fill(s.x, s.y + s.height, s.width, 1, " ")
- gpu.fill(s.x + s.width, s.y, 1, s.height + 1, " ")
- -- set title
- gpu.setBackground(colors.black)
- gpu.set(s.x + 2, s.y, s.title)
- end
- -- Initialize components and move to bottom floor
- function init()
- API.screen()
- event.listen("touch", API.checkxy)
- for k,v in pairs(floors) do
- floorComponents[v] = component.redstone
- floorComponents[v].address = component.proxy(component.get(v))
- end
- for k,v in pairs(screens) do
- gpu.bind(component.get(v))
- clear()
- for section,settings in pairs(sections) do
- printBorders(section)
- print(section)
- end
- end
- component.bind(component.get(screens.main))
- setButtons()
- end
- function draw()
- -- for k,v in pairs(screens) do
- -- gpu.bind(component.get(v))
- -- end
- end
- while event.pull(0.05, "interrupted") == nil do
- local event, address, arg1, arg2, arg3 = event.pull(1)
- if type(address) == "string" and component.isPrimary(address) then
- if event == "key_down" and arg2 == keyboard.keys.q then
- os.exit(1)
- end
- end
- draw()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement