Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- signal = 0
- local gomb = {}
- term.clear()
- gomb[1] = {x = 1, y = 1, x2 = 3, y2 = 1, color = colors.red, szoveg = "1"}
- gomb[2] = {x = 5, y = 1, x2 = 7, y2 = 1, color = colors.yellow, szoveg = "2"}
- gomb[3] = {x = 9, y = 1, x2 = 11, y2 = 1, color = colors.green, szoveg = "3"}
- gomb[4] = {x = 1, y = 3, x2 = 3, y2 = 3, color = colors.orange, szoveg = "4"}
- gomb[5] = {x = 5, y = 3, x2 = 7, y2 = 3, color = colors.magenta, szoveg = "5"}
- gomb[6] = {x = 9, y = 3, x2 = 11, y2 = 3, color = colors.cyan, szoveg = "6"}
- gomb[7] = {x = 1, y = 5, x2 = 3, y2 = 5, color = colors.red, szoveg = "7"}
- gomb[8] = {x = 5, y = 5, x2 = 7, y2 = 5, color = colors.yellow, szoveg = "8"}
- gomb[9] = {x = 9, y = 5, x2 = 11, y2 = 5, color = colors.green, szoveg = "9"}
- function tclr()
- term.clear()
- term.setCursorPos(1,1)
- end
- function kirajzol()
- term.clear()
- 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 setter(i)
- if i == 1 then
- print("gomb ", i, " megnyomva")
- end
- end
- while true 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