Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.find("monitor")
- a = false
- b = false
- c = false
- d = false
- function drawButtons()
- x,y = mon.getSize()
- mon.clear()
- mon.setTextColor(colors.black)
- if a == true then
- mon.setBackgroundColor(colors.white)
- else
- mon.setBackgroundColor(colors.gray)
- end
- for yc = 1, y/2+1 do
- for xc = 1, x/2+1 do
- mon.setCursorPos(xc,yc)
- mon.write(" ")
- end
- end
- mon.setCursorPos(x/4+1, y/4)
- mon.write("1")
- if b == true then
- mon.setBackgroundColor(colors.white)
- else
- mon.setBackgroundColor(colors.gray)
- end
- for yc = 1, y/2+1 do
- for xc = x/2+1, x do
- mon.setCursorPos(xc,yc)
- mon.write(" ")
- end
- end
- mon.setCursorPos(x/4*3+1, y/4)
- mon.write("2")
- if c == true then
- mon.setBackgroundColor(colors.white)
- else
- mon.setBackgroundColor(colors.gray)
- end
- for yc = y/2+1, y do
- for xc = 1, x/2+1 do
- mon.setCursorPos(xc,yc)
- mon.write(" ")
- end
- end
- mon.setCursorPos(x/4+1, y/4*3)
- mon.write("3")
- if d == true then
- mon.setBackgroundColor(colors.white)
- else
- mon.setBackgroundColor(colors.gray)
- end
- for yc = y/2+1, y do
- for xc = x/2+1, x do
- mon.setCursorPos(xc,yc)
- mon.write(" ")
- end
- end
- mon.setCursorPos(x/4*3+1, y/4*3)
- mon.write("4")
- end
- while true do
- drawButtons()
- event, param1, param2, param3 = os.pullEvent("monitor_touch")
- if param2 < x/2 and param3 < y/2 then
- if a == false then
- rs.setOutput("front", true)
- a = true
- else
- rs.setOutput("front", false)
- a = false
- end
- elseif param2 > x/2 and param3 < y/2 then
- if b == false then
- rs.setOutput("right", true)
- b = true
- else
- rs.setOutput("right", false)
- b = false
- end
- elseif param2 < x/2 and param3 > y/2 then
- if c == false then
- rs.setOutput("back", true)
- c = true
- else
- rs.setOutput("back", false)
- c = false
- end
- elseif param2 > x/2 and param3 > y/2 then
- if d == false then
- rs.setOutput("left", true)
- d = true
- else
- rs.setOutput("left", false)
- d = false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement