Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component = require("component")
- term = require("term")
- event = require("event")
- rs = component.redstone
- colors = require("colors")
- gpu = component.gpu
- sides = require("sides")
- args = {...}
- posX = 3
- pressedPass = {}
- gui = {
- [1] = "|-----------|",
- [2] = "| |",
- [3] = "|-----------|",
- [4] = "| 1 | 2 | 3 |",
- [5] = "|-----------|",
- [6] = "| 4 | 5 | 6 |",
- [7] = "|-----------|",
- [8] = "| 7 | 8 | 9 |",
- [9] = "|-----------|",
- [10] = "|[x]| 0 |[v]|",
- [11] = "|-----------|",
- [12] = " "
- }
- pass = {
- [1] = "1",
- [2] = "2",
- [3] = "3",
- [4] = "4",
- }
- function checkPass()
- if pressedPass[1] == pass[1] and pressedPass[2] == pass[2] and pressedPass[3] == pass[3] and pressedPass[4] == pass[4] then
- rs.setBundledOutput(sides.west, colors.red, 15)
- os.sleep(3)
- rs.setBundledOutput(sides.west, colors.red, 0)
- gpu.set(2,2," ")
- else
- pressedPass = nil
- pressedPass = {}
- gpu.set(2,2," ")
- end
- end
- function debug()
- if args[1] == "debug" then
- term.setCursor(1,14)
- for k,v in pairs(pressedPass) do
- print(v)
- end
- end
- end
- function draw()
- for k,v in pairs(gui) do
- gpu.set(1,k, v)
- end
- end
- function checkX()
- posX = posX + 2
- if posX >= 12 then
- gpu.set(2,2, " ")
- posX = 3
- pressedPass = nil
- pressedPass = {}
- end
- end
- gpu.setResolution(14,14)
- draw()
- while true do
- _,_, x, y = event.pull(0.1, "touch")
- if x >= 2 and x <= 4 and y == 4 then -- 1
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "1")
- debug()
- checkX()
- elseif x >= 6 and x <= 8 and y == 4 then -- 2
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "2")
- debug()
- checkX()
- elseif x >= 10 and x <= 12 and y == 4 then -- 3
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "3")
- debug()
- checkX()
- elseif x >= 2 and x <= 4 and y == 6 then -- 4
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "4")
- debug()
- checkX()
- elseif x >= 6 and x <= 8 and y == 6 then -- 5
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "5")
- debug()
- checkX()
- elseif x >= 10 and x <= 12 and y == 6 then -- 6
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "6")
- debug()
- checkX()
- elseif x >= 2 and x <= 4 and y == 8 then -- 7
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "7")
- debug()
- checkX()
- elseif x >= 6 and x <= 8 and y == 8 then -- 8
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "8")
- debug()
- checkX()
- elseif x >= 10 and x <= 12 and y == 8 then -- 9
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "9")
- debug()
- checkX()
- elseif x >= 2 and x <= 4 and y == 10 then -- cancel
- gpu.set(2,2, " ")
- posX = 3
- pressedPass = nil
- pressedPass = {}
- elseif x >= 6 and x <= 8 and y == 10 then --0
- gpu.set(posX, 2, "*")
- table.insert(pressedPass, "0")
- checkX()
- elseif x >= 10 and x <= 12 and y == 10 then
- checkPass()
- elseif x >= 2 and x <= 5 and y == 12 then
- gpu.setResolution(100,50)
- term.clear()
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement