Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("top")
- mon.clear()
- w, h = mon.getSize()
- print(w, " ", h)
- index = 1
- pass = ""
- password = {}
- selecteditem = 1
- mainmenu1 = {}
- mainmenu1[1] = {text = "login", handler = login}
- mainmenu1[2] = {text = "demo2", handler = demo2}
- mainmenu1[3] = {text = "demo3", handler = demo3}
- gomb = {}
- gomb[1] = {x = w-w+1, y = h-2, x2 = w-w+1, y2 = h-2, color = colors.black, dcolor = colors.black, szoveg = "1"}
- gomb[2] = {x = w-w+2, y = h-2, x2 = w-w+2, y2 = h-2, color = colors.black, dcolor = colors.black, szoveg = "2"}
- gomb[3] = {x = w-w+3, y = h-2, x2 = w-w+3, y2 = h-2, color = colors.black, dcolor = colors.black, szoveg = "3"}
- gomb[4] = {x = w-w+4, y = h-2, x2 = w-w+4, y2 = h-2, color = colors.black, dcolor = colors.black, szoveg = "4"}
- gomb[5] = {x = w-w+1, y = h-1, x2 = w-w+1, y2 = h-1, color = colors.black, dcolor = colors.black, szoveg = "5"}
- gomb[6] = {x = w-w+2, y = h-1, x2 = w-w+2, y2 = h-1, color = colors.black, dcolor = colors.black, szoveg = "6"}
- gomb[7] = {x = w-w+3, y = h-1, x2 = w-w+3, y2 = h-1, color = colors.black, dcolor = colors.black, szoveg = "7"}
- gomb[8] = {x = w-w+4, y = h-1, x2 = w-w+4, y2 = h-1, color = colors.black, dcolor = colors.black, szoveg = "8"}
- gomb[9] = {x = w-w+1, y = h, x2 = w-w+1, y2 = h, color = colors.black, dcolor = colors.black, szoveg = "9"}
- gomb[10] = {x = w-w+3, y = h, x2 = w-w+3, y2 = h, color = colors.black, dcolor = colors.black, szoveg = "0"}
- gomb[11] = {x = w-w+2, y = h, x2 = w-w+2, y2 = h, color = colors.black, dcolor = colors.black, szoveg = "*"}
- gomb[12] = {x = w-w+4, y = h, x2 = w-w+4, y2 = h, color = colors.black, dcolor = colors.black, szoveg = "#"}
- gomb[13] = {x = w-w+6, y = h-1, x2 = w-w+10, y2 = h-1, color = colors.green, dcolor = colors.green, szoveg = "enter"}
- gomb[14] = {x = w-w+5, y = h, x2 = w-w+10, y2 = h, color = colors.red, dcolor = colors.red, szoveg = "delete"}
- gomb[15] = {x = w-w+12, y = h, x2 = w-w+12, y2 = h, color = colors.gray, dcolor = colors.gray, szoveg = "<"}
- gomb[16] = {x = w-w+14, y = h, x2 = w-w+14, y2 = h, color = colors.gray, dcolor = colors.gray, szoveg = "v"}
- gomb[17] = {x = w-w+16, y = h, x2 = w-w+16, y2 = h, color = colors.gray, dcolor = colors.gray, szoveg = ">"}
- gomb[18] = {x = w-w+14, y = h-1, x2 = w-w+14, y2 = h-1, color = colors.gray, dcolor = colors.gray, szoveg = "^"}
- function login()
- local event, button, xpos, ypos = os.pullEvent("monitor_touch")
- mon.setCursorPos(1, 1)
- mon.write("login") sleep(2)
- end
- function kirajzol()
- mon.clear()
- for g = 1, 2 do
- for h = 1, w do
- mon.setBackgroundColor(colors.lime)
- mon.setCursorPos(h ,g)
- mon.write(" ")
- end
- end
- 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
- mon.setCursorPos(k, j)
- mon.setBackgroundColor(gomb[i].color)
- mon.write(" ")
- end
- end
- mon.setCursorPos(gomb[i].x, gomb[i].y)
- mon.write(gomb[i].szoveg)
- end
- mon.setBackgroundColor(colors.black)
- end
- function printmenu(menu)
- mon.setBackgroundColor(colors.lime)
- for i = 1, #menu do
- local hossz = string.len(menu[i].text)
- if i == selecteditem then
- mon.setCursorPos(w/2-(hossz/2), 1)
- mon.write("--"..menu[i].text.."--")
- else
- mon.setCursorPos(w/2-(hossz/2), 2)
- if selecteditem < #menu then
- mon.write(" "..menu[selecteditem+1].text.." ")
- else
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function onitemchange(i, menu)
- if i == 15 then -- bal
- elseif i == 16 then -- le
- if selecteditem < #menu then
- selecteditem = selecteditem + 1
- end
- elseif i == 17 then -- jobb
- menu[selecteditem].handler()
- elseif i == 18 then -- fel
- if selecteditem > 1 then
- selecteditem = selecteditem - 1
- end
- end
- 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 intake(i)
- if i > 0 and i < 11 then
- table.insert(password, #password+1, gomb[i].szoveg)
- for i = 1, #password do
- mon.setCursorPos(i, 1)
- mon.write(password[i])
- end
- local temporary = password[#password]
- pass = pass..temporary
- elseif i == 10 then
- mon.setCursorPos(1, 1)
- mon.write("reset") sleep(3)
- pass = ""
- password = {}
- elseif i == 12 then
- if pass == "1" then
- mon.setCursorPos(1, 1)
- mon.write("granted")
- password = {}
- pass = ""
- rs.setOutput("bottom", true)
- sleep(1)
- rs.setOutput("bottom", false)
- else
- mon.setCursorPos(1, 1)
- mon.write("denied")
- password = {}
- pass = "" sleep(2)
- end
- elseif i > 14 and i < 19 then
- onitemchange(i, mainmenu1)
- end
- end
- while true do
- kirajzol()
- printmenu(mainmenu1)
- local event, button, xpos, ypos = os.pullEvent("monitor_touch")
- for i=1, #gomb do
- if click(xpos, ypos, gomb[i].x, gomb[i].y, gomb[i].x2, gomb[i].y2) then
- print(gomb[i].szoveg)
- intake(i)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement