Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local g = component.gpu
- local term = require("term")
- local colors = require("colors")
- local event = require("event")
- local red = component.redstone
- local sides = require("sides")
- local code = "125879"
- local input = ""
- local delay = 2
- local side = 3
- local show = true
- args = {...}
- if args[1] ~= nil and args[1] ~= "_" then
- code = args[1]
- end
- if args[2] ~= nil and args[2] ~= "_" then
- for i=0,5 do
- if sides[i] == args[2] then
- side = i
- break
- end
- end
- end
- if args[3] ~= nil and args[3] ~= "_" then
- delay = tonumber(args[3])
- end
- if args[4] ~= nil and args[4] == "false" then
- show = false
- end
- g.setResolution(30,15)
- g.setBackground(colors.silver, true)
- term.clear()
- function drawDot(number, color)
- local x = 3+math.fmod(number+2,3)*10
- local y = 2+(math.ceil(number/3)-1)*5
- g.setBackground(color, true)
- g.fill(x,y,6,3," ")
- g.setBackground(colors.white, true)
- g.fill(x+2,y+1,2,1," ")
- end
- function drawDots()
- for i=1,9 do
- drawDot(i,colors.cyan)
- end
- end
- drawDots()
- local doing = false
- while true do
- local event, _, x, y = event.pull(0.3)
- if event == "touch" then
- if not doing then
- doing = true
- end
- if (not show and math.fmod(x, 10) > 2 and math.fmod(x, 10) < 9 and math.fmod(y, 5) > 1 and math.fmod(y, 5) < 5) or show then
- local button = (math.ceil(y/5)-1)*3+math.ceil((x)/10)
- if show then
- drawDot(button, colors.lime)
- end
- if string.find(input, tostring(button)) == nil then
- input = input..tostring(button)
- end
- end
- elseif event == nil then
- if doing then
- if show then
- drawDots()
- end
- if input == code then
- red.setOutput(side, 15)
- os.sleep(delay)
- red.setOutput(side, 0)
- end
- input = ""
- doing = false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement