Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- w, h = term.getSize()
- run = true
- gomb = {}
- gomb[1] = {xs = w/2-2, ys = h-7, xe = w/2+2, ye = h-7, color = colors.red, text = "up"}
- gomb[2] = {xs = w/2-2, ys = h-5, xe = w/2+2, ye = h-5, color = colors.red, text = "fd"}
- gomb[3] = {xs = w/2-2, ys = h-3, xe = w/2+2, ye = h-3, color = colors.red, text = "back"}
- gomb[4] = {xs = w/2-2, ys = h-1, xe = w/2+2, ye = h-1, color = colors.green, text = "down"}
- gomb[5] = {xs = w/2-8, ys = h-3, xe = w/2-4, ye = h-1, color = colors.white, text = "left"}
- gomb[6] = {xs = w/2+4, ys = h-3, xe = w/2+8, ye = h-1, color = colors.yellow, text = "right"}
- gomb[7] = {xs = w/2-8, ys = h-7, xe = w/2-4, ye = h-7, color = colors.magenta, text = "pl.up"}
- gomb[8] = {xs = w/2-8, ys = h-6, xe = w/2-4, ye = h-6, color = colors.orange, text = "place"}
- gomb[9] = {xs = w/2-8, ys = h-5, xe = w/2-4, ye = h-5, color = colors.blue, text = "pl.dn"}
- gomb[10] = {xs = w/2+4, ys = h-7, xe = w/2+8, ye = h-7, color = colors.magenta, text = "rs.up"}
- gomb[11] = {xs = w/2+4, ys = h-6, xe = w/2+8, ye = h-6, color = colors.orange, text = "rs"}
- gomb[12] = {xs = w/2+4, ys = h-5, xe = w/2+8, ye = h-5, color = colors.blue, text = "rs.dn"}
- function printbutton()
- term.clear()
- for i = 1, #gomb do
- if gomb[i].color == term.getTextColor() then
- term.setBackgroundColor(gomb[i].color)
- term.setTextColor(colors.red)
- else
- term.setBackgroundColor(gomb[i].color)
- end
- for j = gomb[i].ys, gomb[i].ye do
- for k = gomb[i].xs, gomb[i].xe do
- term.setCursorPos(k, j)
- print(" ")
- end
- end
- term.setCursorPos(gomb[i].xs, gomb[i].ys)
- print(gomb[i].text)
- term.setTextColor(colors.white)
- end
- term.setBackgroundColor(colors.black)
- end
- function mouseclick(x, y, xs, ys, xe, ye)
- if x < xs or y < ys or x > xe or y > ye then
- return false
- end
- return true
- end
- function setter(i)
- print(i, " -es gomb megnyomva!")
- if i == 1 then --up
- rednet.broadcast(gomb[i].text)
- print(i, " gomb megnyomva!")
- elseif i == 2 then --forward
- rednet.broadcast(gomb[i].text)
- elseif i == 3 then --back
- rednet.broadcast(gomb[i].text)
- elseif i == 4 then --down
- rednet.broadcast(gomb[i].text)
- elseif i == 5 then --left
- rednet.broadcast(gomb[i].text)
- elseif i == 6 then -- right
- rednet.broadcast(gomb[i].text)
- elseif i == 7 then -- placeup
- rednet.broadcast(gomb[i].text)
- elseif i == 8 then -- place
- rednet.broadcast(gomb[i].text)
- elseif i == 9 then -- placedown
- rednet.broadcast(gomb[i].text)
- elseif i == 10 then -- rs up
- rednet.broadcast(gomb[i].text)
- elseif i == 11 then -- rs
- rednet.broadcast(gomb[i].text)
- elseif i == 12 then -- rs down
- rednet.broadcast(gomb[i].text)
- end
- sleep(.3)
- end
- while run do
- printbutton()
- mytimer = os.startTimer(.1)
- event, btn, x, y = os.pullEvent()
- --[[ if event == "timer" and btn == mytimer then
- term.setCursorPos(1, 1)
- print("timer lejart") sleep(1)]]
- if event == "mouse_click" then
- for i = 1, #gomb do
- if mouseclick(x, y, gomb[i].xs, gomb[i].ys, gomb[i].xe, gomb[i].ye) then
- setter(i)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement