Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("top")
- w, h = m.getSize()
- run = true
- text = ""
- local gomb = {}
- m.clear()
- gomb[1] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "1"}
- gomb[2] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "2"}
- gomb[3] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "3"}
- gomb[4] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "4"}
- gomb[5] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "5"}
- gomb[6] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "6"}
- gomb[7] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "7"}
- gomb[8] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "8"}
- gomb[9] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "9"}
- gomb[10] = {x = nil, y = nil, x2 = nil, y2 = nil, color = nil, szoveg = "0"}
- gomb[11] = {x = 1, y = h-1, x2 = 3, y2 = h-1, color = colors.gray, szoveg = "*"}
- gomb[12] = {x = 9, y = h-1, x2 = 11, y2 = h-1, color = colors.gray, szoveg = "#"}
- gomb[13] = {x = 13, y = h-1, x2 = 15, y2 = h-1, color = colors.red, szoveg = "c"}
- gomb2 = {}
- gomb2[1] = {x = 1, y = h-7, x2 = 3, y2 = h-7}
- gomb2[2] = {x = 5, y = h-7, x2 = 7, y2 = h-7}
- gomb2[3] = {x = 9, y = h-7, x2 = 11, y2 = h-7}
- gomb2[4] = {x = 1, y = h-5, x2 = 3, y2 = h-5}
- gomb2[5] = {x = 5, y = h-5, x2 = 7, y2 = h-5}
- gomb2[6] = {x = 9, y = h-5, x2 = 11, y2 = h-5}
- gomb2[7] = {x = 1, y = h-3, x2 = 3, y2 = h-3}
- gomb2[8] = {x = 5, y = h-3, x2 = 7, y2 = h-3}
- gomb2[9] = {x = 9, y = h-3, x2 = 11, y2 = h-3}
- gomb2[10] = {x = 5, y = h-1, x2 = 7, y2 = h-1}
- szinek = {}
- szinek[1] = {color = 2}
- szinek[2] = {color = 4}
- szinek[3] = {color = 8}
- szinek[4] = {color = 16}
- szinek[5] = {color = 32}
- szinek[6] = {color = 64}
- szinek[7] = {color = 128}
- szinek[8] = {color = 256}
- szinek[9] = {color = 512}
- szinek[10] = {color = 1024}
- szamok = {}
- szin = {}
- function kiir(szoveg)
- hossz = string.len(szoveg)
- m.clear()
- m.setCursorPos(w/2-(hossz/2), h/2)
- m.write(szoveg)
- sleep(3)
- end
- function rand()
- while #szamok < #gomb2 do
- dobottszam = math.random(1, #gomb2)
- table.insert(szamok, dobottszam)
- index = 0
- for i = 1, #szamok do
- if dobottszam == szamok[i] then
- index = index + 1
- if index > 1 then
- table.remove(szamok, i , dobottszam)
- end
- end
- end
- end
- while #szin < #gomb2 do
- szinszam = math.random(1, #gomb2)
- table.insert(szin, szinszam)
- index = 0
- for k = 1, #szin do
- if szinszam == szin[k] then
- index = index + 1
- if index > 1 then
- table.remove(szin, k , szinszam)
- end
- end
- end
- end
- for j = 1, #gomb2 do
- szam = szamok[j]
- dobottszin = szin[j]
- gomb[j].x = gomb2[szam].x
- gomb[j].y = gomb2[szam].y
- gomb[j].x2 = gomb2[szam].x2
- gomb[j].y2 = gomb2[szam].y2
- gomb[j].color = szinek[dobottszin].color
- end
- szamok = {}
- szin = {}
- end
- function textbox()
- bal = gomb[1].x
- jobb = gomb[1].x2
- for h = 1, #gomb do
- if gomb[h].x < bal then
- bal = gomb[h].x
- end
- if gomb[h].x2 > jobb then
- jobb = gomb[h].x2
- end
- end
- for i = bal, jobb do
- m.setCursorPos(i, h-9)
- m.setBackgroundColor(colors.lime)
- m.write(" ")
- end
- bal2 = bal
- hossz = string.len(text)
- if hossz > jobb then
- text = ""
- bal = bal2
- m.setCursorPos(bal, h-9)
- m.write("tulcsordult")
- password = 0 sleep(1)
- else
- for j = 1, hossz do
- m.setCursorPos(j, h-9)
- m.write("*")
- end
- end
- end
- function kirajzol()
- m.clear()
- textbox()
- 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
- m.setCursorPos(k, j)
- m.setBackgroundColor(gomb[i].color)
- m.write(" ")
- end
- end
- m.setCursorPos(gomb[i].x+1, gomb[i].y)
- m.write(gomb[i].szoveg)
- end
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- end
- function paint()
- m.clear()
- for i = 1, #gomb do
- paintutils.drawFilledBox(gomb[i].x, gomb[i].y, gomb[i].x2, gomb[i].y2, gomb[i].color)
- m.setCursorPos(gomb[i].x+1, gomb[i].y)
- print(gomb[i].szoveg)
- end
- m.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 passcheck(szoveg)
- if text == "0" then
- kiir("access")
- elseif text == "1987" then
- kiir("access")
- m.clear()
- m.setCursorPos(1, 1)
- m.write("CraftOS ")
- m.setCursorPos(1, 2)
- m.write(os.version())
- run = false
- else
- kiir("deny")
- end
- print("kod: ", text)
- sleep(2)
- text = ""
- end
- function setter(i)
- if gomb[i].szoveg == "c" then
- text = ""
- elseif gomb[i].szoveg == "#" then
- passcheck()
- else
- text = text..gomb[i].szoveg
- print("text: ", text)
- end
- end
- while run do
- rand()
- kirajzol()
- local event, button, xpos, ypos = os.pullEventRaw()
- if event == "terminate" then
- kiir("Ne lopj!")
- elseif event == "monitor_touch" then
- 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
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement