Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- w, h = term.getSize()
- run = true
- tempcolor = nil
- password = ""
- local gomb = {}
- term.clear()
- gomb[1] = {x = 1, y = 3, x2 = 3, y2 = 3, color = colors.red, szoveg = "1"}
- gomb[2] = {x = 5, y = 3, x2 = 7, y2 = 3, color = colors.red, szoveg = "2"}
- gomb[3] = {x = 9, y = 3, x2 = 11, y2 = 3, color = colors.red, szoveg = "3"}
- gomb[4] = {x = 1, y = 5, x2 = 3, y2 = 5, color = colors.red, szoveg = "4"}
- gomb[5] = {x = 5, y = 5, x2 = 7, y2 = 5, color = colors.red, szoveg = "5"}
- gomb[6] = {x = 9, y = 5, x2 = 11, y2 = 5, color = colors.red, szoveg = "6"}
- gomb[7] = {x = 1, y = 7, x2 = 3, y2 = 7, color = colors.red, szoveg = "7"}
- gomb[8] = {x = 5, y = 7, x2 = 7, y2 = 7, color = colors.red, szoveg = "8"}
- gomb[9] = {x = 9, y = 7, x2 = 11, y2 = 7, color = colors.red, szoveg = "9"}
- gomb[10] = {x = 1, y = 9, x2 = 3, y2 = 9, color = colors.red, szoveg = "*"}
- gomb[11] = {x = 5, y = 9, x2 = 7, y2 = 9, color = colors.red, szoveg = "0"}
- gomb[12] = {x = 9, y = 9, x2 = 11, y2 = 9, color = colors.red, szoveg = "#"}
- function tclr()
- term.clear()
- term.setCursorPos(1,1)
- end
- function kirajzol()
- term.clear()
- term.setTextColor(colors.yellow)
- term.setBackgroundColor(colors.green)
- for i = 1, 11 do
- for j = 1, 1 do
- term.setCursorPos(i, j)
- term.write(" ")
- hossz = string.len(password)
- term.setCursorPos(12/2-(hossz/2)+1, 1)
- term.write(password)
- end
- end
- term.setTextColor(colors.white)
- for i = 1, #gomb do
- for j = 0 + gomb[i].y, gomb[i].y2 do
- for k = 0 + gomb[i].x, gomb[i].x2 do
- term.setCursorPos(k, j)
- term.setBackgroundColor(gomb[i].color)
- print(" ")
- end
- end
- term.setCursorPos(gomb[i].x+1, gomb[i].y)
- print(gomb[i].szoveg)
- end
- term.setBackgroundColor(colors.black)
- end
- function paint()
- term.clear()
- for i = 1, #gomb do
- paintutils.drawFilledBox(gomb[i].x, gomb[i].y, gomb[i].x2, gomb[i].y2, gomb[i].color)
- term.setCursorPos(gomb[i].x+1, gomb[i].y)
- print(gomb[i].szoveg)
- end
- term.setBackgroundColor(colors.black)
- end
- function click(xpos, ypos, xs, ys, xe, ye)
- if xpos < xs or xpos > xe or ypos < ys or ypos > ye then
- return false
- else
- return true
- end
- end
- function jelszo()
- if password == "123" then
- password = "elfogadva"
- elseif password == "0000" then
- run = false
- else
- password = "megtagadva"
- end
- end
- function setter(i)
- tempcolor = gomb[i].color
- gomb[i].color = colors.white
- kirajzol()
- sleep(.2)
- gomb[i].color = tempcolor
- if i == 1 then
- password = password..1
- elseif i == 2 then
- password = password..2
- elseif i == 3 then
- password = password..3
- elseif i == 4 then
- password = password..4
- elseif i == 5 then
- password = password..5
- elseif i == 6 then
- password = password..6
- elseif i == 7 then
- password = password..7
- elseif i == 8 then
- password = password..8
- elseif i == 9 then
- password = password..9
- elseif i == 10 then
- password = ""
- kirajzol()
- elseif i == 11 then
- password = password..0
- elseif i == 12 then
- jelszo()
- end
- end
- while run do
- kirajzol()
- local event, button, xpos, ypos = os.pullEvent("mouse_click")
- for i=1, #gomb do
- if click(xpos, ypos, gomb[i].x, gomb[i].y, gomb[i].x2, gomb[i].y2) then
- setter(i)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement