Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("top")
- signal = 0
- local gomb = {}
- term.clear()
- gomb[1] = {x = 1, y = 1, x2 = 3, y2 = 1, color = colors.red, dcolor = colors.red, szoveg = "a", value = 1}
- gomb[2] = {x = 5, y = 1, x2 = 7, y2 = 1, color = colors.yellow, dcolor = colors.yellow, szoveg = "b", value = 0}
- gomb[3] = {x = 9, y = 1, x2 = 11, y2 = 1, color = colors.green, dcolor = colors.green, szoveg = "c", value = 0}
- gomb[4] = {x = 1, y = 3, x2 = 3, y2 = 3, color = colors.orange, dcolor = colors.orange, szoveg = "d", value = 0}
- gomb[5] = {x = 5, y = 3, x2 = 7, y2 = 3, color = colors.magenta, dcolor = colors.magenta, szoveg = "e", value = 0}
- gomb[6] = {x = 9, y = 3, x2 = 11, y2 = 3, color = colors.cyan, dcolor = colors.cyan, szoveg = "f", value = 0}
- gomb[7] = {x = 41, y = 1, x2 = 43, y2 = 1, color = 2, dcolor = 2, szoveg = "1", value = 0}
- gomb[8] = {x = 45, y = 1, x2 = 47, y2 = 1, color = 4, dcolor = 4, szoveg = "2", value = 0}
- gomb[9] = {x = 49, y = 1, x2 = 51, y2 = 1, color = 8, dcolor = 8, szoveg = "3", value = 0}
- gomb[10] = {x = 41, y = 3, x2 = 43, y2 = 3, color = 16, dcolor = 16, szoveg = "4", value = 0}
- function tclr()
- mon.clear()
- mon.setCursorPos(1,1)
- end
- function kirajzol()
- mon.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
- mon.setCursorPos(k, j)
- mon.setBackgroundColor(gomb[i].color)
- mon.write(" ")
- end
- end
- mon.setCursorPos(gomb[i].x+1, gomb[i].y)
- mon.write(gomb[i].szoveg)
- end
- mon.setBackgroundColor(colors.black)
- end
- function paint()
- mon.clear()
- for i = 1, #gomb do
- paintutils.drawFilledBox(gomb[i].x, gomb[i].y, gomb[i].x2, gomb[i].y2, gomb[i].color)
- mon.setCursorPos(gomb[i].x+1, gomb[i].y)
- mon.write(gomb[i].szoveg)
- 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 setter(ertek, xpos, ypos, i, xs, ys, xe, ye)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- if ertek then
- if gomb[i].color == gomb[i].dcolor then
- esemeny(i)
- gomb[i].color = colors.lime
- else
- esemeny(i)
- gomb[i].color = gomb[i].dcolor
- end
- else
- mon.setCursorPos(xpos, ypos)
- mon.write("x")
- end
- end
- function esemeny(i)
- if gomb[i].color == gomb[i].dcolor then
- if i == 1 then
- rs.setOutput("left", true)
- elseif i == 2 then
- rs.setOutput("right", true)
- elseif i == 3 then
- rednet.broadcast("open")
- elseif i == 4 then
- redstone.setAnalogOutput("left", signal)
- elseif i == 9 then
- signal = 3
- end
- else
- if i == 1 then
- rs.setOutput("left", false)
- elseif i == 2 then
- rs.setOutput("right", false)
- elseif i == 3 then
- rednet.broadcast("close")
- elseif i == 4 then
- redstone.setAnalogOutput("left", 0)
- elseif i == 9 then
- signal = 0
- end
- end
- end
- while true do
- kirajzol()
- 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
- setter(true, xpos, ypos, i, gomb[i].x, gomb[i].y, gomb[i].x2, gomb[i].y2)
- else
- setter(false, xpos, ypos, i, gomb[i].x, gomb[i].y, gomb[i].x2, gomb[i].y2)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement