Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function load()
- os.loadAPI("touchpoint")
- os.loadAPI("bundleAPI")
- pa1 = touchpoint.new("left")
- pa2 = touchpoint.new("left")
- color = {}
- monitor = {}
- end
- function setMonitors()
- p1S = true
- p2S = false
- p3S = false
- end
- function getColor(name)
- return color[name]
- end
- function getMonitor(name)
- return monitor[name]
- end
- function loadButtons()
- -- Line 1 --
- pa1:add("Netherstar Gen", nil, 2, 2, 20, 4, colors.red, colors.lime)
- NG = "Netherstar Gen"
- color[NG] = "lime"
- monitor[NG] = "pa1"
- pa1:add("Wither Spawner", nil, 22, 2, 40, 4, colors.lime, colors.red)
- WS = "Wither Spawner"
- color[WS] = "cyan"
- monitor[WS] = "pa1"
- pa1:add("Mana C Spawner", nil, 42, 2, 60, 4, colors.red, colors.lime)
- MCS = "Mana C Spawner"
- color[MCS] = "white"
- monitor[MCS] = "pa1"
- -- Line 2 --
- pa1:add("Obsidian Prod", nil, 2 , 6, 20, 8, colors.red, colors.lime)
- OP = "Obsidian Prod"
- color[OP] = "orange"
- monitor[OP] = "pa1"
- pa1:add("Lava Production", nil, 22, 6, 40, 8, colors.lime, colors.red)
- LP = "Lava Production"
- color[LP] = "blue"
- monitor[LP] = "pa1"
- pa1:add("Test Button", nil, 42, 6, 60, 8, colors.red, colors.lime)
- TB = "Test Button"
- color[TB] = "purple"
- monitor[TB] = "pa1"
- -- Line 3 --
- pa1:add("Previous", nil, 2, 10, 15, 12, colors.gray, colors.gray)
- pa1:add("Next", nil, 45, 10, 60, 12, colors.gray, colors.gray)
- end
- function buttonPress()
- local event, p1 = pa1:handleEvents(os.pullEvent())
- if event == "button_click" then
- pa1:toggleButton(p1)
- if not p1 == "Previous" or "Next" then
- bundleAPI.toggle("back", getColor(p1))
- else
- print("Button not yet added")
- end
- end
- end
- function toggleOn(name)
- bundleAPI.on("back", getColor(name))
- end
- function toggleOff(name)
- bundleAPI.off("back", getColor(name))
- end
- function getStates()
- c = bundleAPI.getInput("top", "cyan")
- l = bundleAPI.getInput("top", "lime")
- w = bundleAPI.getInput("top", "white")
- o = bundleAPI.getInput("top", "orange")
- b = bundleAPI.getInput("top", "blue")
- p = bundleAPI.getInput("top", "purple")
- print("Current states:" .. tostring(c) .. tostring(l) .. tostring(w) .. tostring(o) .. tostring(b) .. tostring(p))
- print("cyan, lime, white, orange, blue, purple")
- end
- function setStates()
- if c == true then
- toggleOn("Wither Spawner")
- pa1:setOn("Wither Spawner")
- else
- toggleOff("Wither Spawner")
- pa1:setOff("Wither Spawner")
- end
- if l == true then
- toggleOn("Netherstar Gen")
- pa1:setOn("Netherstar Gen")
- else
- toggleOff("Netherstar Gen")
- pa1:setOff("Netherstar Gen")
- end
- if w == true then
- toggleOn("Mana C Spawner")
- pa1:setOn("Mana C Spawner")
- else
- toggleOff("Mana C Spawner")
- pa1:setOff("Mana C Spawner")
- end
- if o == true then
- toggleOn("Obsidian Prod")
- pa1:setOn("Obsidian Prod")
- else
- toggleOff("Obsidian Prod")
- pa1:setOff("Obsidian Prod")
- end
- if b == true then
- toggleOn("Lava Production")
- pa1:setOn("Lava Production")
- else
- toggleOff("Lava Production")
- pa1:setOff("Lava Production")
- end
- if p == true then
- toggleOn("Test Button")
- pa1:setOn("Test Button")
- else
- toggleOff("Test Button")
- pa1:setOff("Test Button")
- end
- end
- function render()
- if p1S == true then
- pa1:draw()
- elseif p2S == true then
- pa2:draw()
- end
- end
- function run()
- while true do
- buttonPress()
- render()
- end
- end
- function startup()
- load()
- setMonitors()
- loadButtons()
- getStates()
- setStates()
- end
- -- Actual Program --
- startup()
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement