Advertisement
m4rv

PortalControl (einfach)

Jul 2nd, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. -- einfacher Code für den Portal Control Computer mit Touchscreen
  2. -- hier mit meiner Testanordnung mit 3 Linking Books
  3. -- die "435" beim rednet.send ist die ID der angesprochenen Turtle und muss entsprechend auch angepasst werden
  4.  
  5.  
  6. term.clear()
  7. m = peripheral.wrap("top") --sollte durch entsprechendes startup nicht gebraucht werden
  8. m.setTextScale(1)
  9. rednet.open("right")
  10.  
  11. term.setCursorPos(1,1)
  12. print("[X] Links")
  13. term.setCursorPos(1,2)
  14. print("[X] Mitte")
  15. term.setCursorPos(15,2)
  16. print("[X] Rechts")
  17.  
  18. while true do
  19. event,side,x,y = os.pullEvent()
  20.     if event == "monitor_touch" then
  21.         if x >=1 and x <= 4 and y == 1 then
  22.         term.setCursorPos(4,4)
  23.         term.clearLine()
  24.         rednet.send(435, "TestLinks")
  25.         print("Links geklickt")
  26.         sleep(2)
  27.  
  28.         elseif x >=1 and x <= 4 and y == 2 then
  29.         term.setCursorPos(4,4)
  30.         term.clearLine()
  31.         rednet.send(435, "TestMitte")
  32.         print("Mitte geklickt")
  33.         sleep(2)
  34.  
  35.         elseif x >=15 and x <= 18 and y == 2 then
  36.         term.setCursorPos(4,4)
  37.         term.clearLine()
  38.         rednet.send(435, "TestRechts")
  39.         print("Rechts geklickt")
  40.         sleep(2)
  41.  
  42.         end
  43.     end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement