Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("left")
- x, y = mon.getSize()
- function switch(side)
- if rs.getInput(side) == true then
- rs.setOutput(side,false) else
- rs.setOutput(side, true)
- end
- end
- function only_up()
- switch("top")
- end
- function only_down()
- switch("bottom")
- end
- function allon()
- rs.setOutput("top",false)
- rs.setOutput("bottom",false)
- end
- function alloff()
- rs.setOutput("top",true)
- rs.setOutput("bottom",true)
- end
- function mepscreen()
- local tx = tonumber(x/2)+1
- local ty = tonumber(y/2)+1
- local ttx = 1
- local tty = 1
- while ttx <x+1 do
- mon.setCursorPos(ttx,ty)
- ttx = ttx + 1
- mon.write("X")
- end
- while tty <y+1 do
- mon.setCursorPos(tx,tty)
- tty = tty + 1
- mon.write("X")
- end
- end
- function detection()
- local mx, my = mon.getSize()
- local tevent, cote, tax, tay = os.pullEvent("monitor_touch")
- local xcol,ycol
- if tax < mx/2 then xcol = 1
- else xcol = 2
- end
- if tay < my/2 then ycol = 1
- elseif ycol = 2
- end
- if xcol == 1 and ycol == 1 then only_up()
- elseif xcol == 2 and ycol == 1 then only_down()
- elseif xcol == 1 and ycol == 2 then allon()
- elseif xcol == 2 and ycol == 2 then alloff()
- end
- term.setCursorPos(1,2)
- term.print("xcol: " .. xcol .. ", yco2: " .. yco2)
- end
- --term.clear()
- term.setCursorPos(1,1)
- print(tax .. " " .. tay )
- end
- while true do
- --term.clear()
- mon.clear()
- mepscreen()
- detection()
- os.sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement