Advertisement
ecco7777

Map turtle Fernsteuerung

Apr 19th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("right")
  2. id=8767
  3. x=20
  4. y=7
  5. dir=1
  6. term.clear()
  7. term.setCursorPos(x,y)
  8.  while true do
  9.         local sEvent, param = os.pullEvent("key")
  10.        
  11.             if param == 200 then
  12.         rednet.send(id,"Forward")
  13.                 sleep(0.2)
  14.         end
  15.  
  16.             if param == 203 then
  17.         rednet.send(id,"Left")
  18.                 sleep(0.2)
  19.         end
  20.  
  21.             if param == 205 then
  22.         rednet.send(id,"Right")
  23.                 sleep(0.2)
  24.         end
  25.  
  26.             if param == 208 then
  27.         rednet.send(id,"Back")
  28.                 sleep(0.2)
  29.         end
  30.  
  31.             if param == 52 then
  32.         rednet.send(id,"Dig")
  33.                 sleep(0.2)
  34.         end
  35.  
  36.             if param == 12 then
  37.         rednet.send(id,"Place")
  38.                 sleep(0.2)
  39.         end
  40.  
  41.             if param == 17 then
  42.         rednet.send(id,"Up")
  43.                 sleep(0.2)
  44.         end
  45.  
  46.             if param == 31 then
  47.         rednet.send(id,"Down")
  48.                 sleep(0.2)
  49.         end
  50.            
  51.  
  52.     id,recall,distance=rednet.receive()
  53.  
  54.  
  55.     if recall=="Right" then
  56.     dir=dir+1
  57.         end
  58.    
  59.     if recall=="Left" then
  60.         dir=dir-1
  61.         end
  62.  
  63.     if dir<1 then
  64.     dir=4
  65.     end
  66.  
  67.     if dir>4 then
  68.     dir=1
  69.     end
  70.  
  71.     if dir==1 then
  72.     look="^"
  73.     end
  74.     if dir==2 then
  75.     look=">"
  76.     end
  77.     if dir==3 then
  78.     look="v"
  79.     end
  80.     if dir==4 then
  81.     look="<"
  82.     end
  83.    
  84.     if recall=="Forward" then
  85.     if dir==1 then
  86.     y=y-1
  87.     end
  88.     if dir==2 then
  89.     x=x+1
  90.     end
  91.     if dir==3 then
  92.     y=y+1
  93.     end
  94.     if dir==4 then
  95.     x=x-1
  96.     end
  97.         end
  98.  
  99.     if recall=="Back" then
  100.     if dir==1 then
  101.     y=y+1
  102.     end
  103.     if dir==2 then
  104.     x=x-1
  105.     end
  106.     if dir==3 then
  107.     y=y-1
  108.     end
  109.     if dir==4 then
  110.     x=x+1
  111.     end
  112.         end
  113.  
  114.     if recall=="blocked" then
  115.         end
  116.         term.setCursorPos(x,y)
  117.     term.write(look)
  118.  
  119.        
  120.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement