Advertisement
appollon41

Digicode by Appo V0.2.7

Jul 31st, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. mon = peripheral.wrap("left")
  2.  
  3. x, y = mon.getSize()
  4.  
  5. function switch(side)
  6. if rs.getInput(side) == true then
  7. rs.setOutput(side,false) else
  8. rs.setOutput(side, true)
  9. end
  10. end
  11.  
  12. function only_up()
  13. switch("top")
  14. end
  15.  
  16. function only_down()
  17. switch("bottom")
  18. end
  19.  
  20. function allon()
  21. rs.setOutput("top",false)
  22. rs.setOutput("bottom",false)
  23. end
  24.  
  25. function alloff()
  26. rs.setOutput("top",true)
  27. rs.setOutput("bottom",true)
  28. end
  29.  
  30. function mepscreen()
  31. local tx = tonumber(x/2)+1
  32. local ty = tonumber(y/2)+1
  33. local ttx = 1
  34. local tty = 1
  35. while ttx <x+1 do
  36. mon.setCursorPos(ttx,ty)
  37. ttx = ttx + 1
  38. mon.write("X")
  39. end
  40.  
  41. while tty <y+1 do
  42. mon.setCursorPos(tx,tty)
  43. tty = tty + 1
  44. mon.write("X")
  45. end
  46. end
  47.  
  48. function detection()
  49. local mx, my = mon.getSize()
  50. local tevent, cote, tax, tay = os.pullEvent("monitor_touch")
  51. local xcol,ycol
  52. if tax < mx/2 then xcol = 1
  53. else xcol = 2
  54. end
  55.  
  56. if tay < my/2 then ycol = 1
  57. elseif ycol = 2
  58. end
  59.  
  60. if xcol == 1 and ycol == 1 then only_up()
  61. elseif xcol == 2 and ycol == 1 then only_down()
  62. elseif xcol == 1 and ycol == 2 then allon()
  63. elseif xcol == 2 and ycol == 2 then alloff()
  64. end
  65.  
  66. term.setCursorPos(1,2)
  67. term.print("xcol: " .. xcol .. ", yco2: " .. yco2)
  68.  
  69. end
  70.  
  71. --term.clear()
  72. term.setCursorPos(1,1)
  73. print(tax .. " " .. tay )
  74.  
  75. end
  76.  
  77. while true do
  78. --term.clear()
  79. mon.clear()
  80. mepscreen()
  81. detection()
  82.  
  83. os.sleep(2)
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement