Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- w, h = term.getSize()
- text = ""
- local gomb = {}
- term.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 = 9, x2 = 3, y2 = 9, color = colors.gray, szoveg = "*"}
- gomb[12] = {x = 9, y = 9, x2 = 11, y2 = 9, color = colors.gray, szoveg = "#"}
- gomb2 = {}
- gomb2[1] = {x = 1, y = 3, x2 = 3, y2 = 3}
- gomb2[2] = {x = 5, y = 3, x2 = 7, y2 = 3}
- gomb2[3] = {x = 9, y = 3, x2 = 11, y2 = 3}
- gomb2[4] = {x = 1, y = 5, x2 = 3, y2 = 5}
- gomb2[5] = {x = 5, y = 5, x2 = 7, y2 = 5}
- gomb2[6] = {x = 9, y = 5, x2 = 11, y2 = 5}
- gomb2[7] = {x = 1, y = 7, x2 = 3, y2 = 7}
- gomb2[8] = {x = 5, y = 7, x2 = 7, y2 = 7}
- gomb2[9] = {x = 9, y = 7, x2 = 11, y2 = 7}
- gomb2[10] = {x = 5, y = 9, x2 = 7, y2 = 9}
- 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 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 g = 1, 2 do
- for h = bal, jobb do
- term.setCursorPos(h, g)
- term.setBackgroundColor(colors.lime)
- print(" ")
- end
- end
- term.setCursorPos(bal, 1)
- print(text)
- end
- function kirajzol()
- 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
- term.setCursorPos(k, j)
- term.setBackgroundColor(gomb[i].color)
- print(" ")
- end
- end
- term.setCursorPos(gomb[i].x+1, gomb[i].y)
- term.setTextColor(colors.red)
- print(gomb[i].szoveg)
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- 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 setter(i)
- text = text..gomb[i].szoveg
- if gomb[i].szoveg == "*" then
- text = ""
- end
- end
- while true do
- rand()
- 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