Advertisement
loepie

Untitled

May 11th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Information --
  2. -- de = Direction North determined by cable color --
  3. -- de = Direction East determined by cable color --
  4. -- ds = Direction South determined by cable color --
  5. -- dw = Direction West determined by cable color --
  6. -- dm = Default block movement --
  7.  
  8. dn = colors.lime
  9. de = colors.purple
  10. ds = colors.orange
  11. dw = colors.lightBlue
  12. rs = redstone
  13. dm = 75
  14.  
  15. function moveNorth(nTimes)
  16.     for i = 1, nTimes , 0.7 do
  17.         rs.setBundledOutput("left", dn)
  18.         sleep(0.7)
  19.         rs.setBundledOutput("left", 0)
  20.         sleep(0.7)
  21.         rs.setBundledOutput("left", dn)
  22.         sleep(0.7)
  23.         rs.setBundledOutput("left", 0)
  24.         term.clear()
  25.         print("Moved ", i, " out of ", nTimes, " blocks.")
  26.     end
  27. end
  28.  
  29. function moveEast(nTimes)
  30.     for i = 1, nTimes , 0.7 do
  31.         rs.setBundledOutput("left", de)
  32.         sleep(0.7)
  33.         rs.setBundledOutput("left", 0)
  34.         sleep(0.7)
  35.         rs.setBundledOutput("left", de)
  36.         sleep(0.7)
  37.         rs.setBundledOutput("left", 0)
  38.         term.clear()
  39.         print("Moved ", i, " out of ", nTimes, " blocks.")
  40.     end
  41. end
  42.  
  43. function moveSouth(nTimes)
  44.     for i = 1, nTimes , 0.7 do
  45.         rs.setBundledOutput("left", ds)
  46.         sleep(0.7)
  47.         rs.setBundledOutput("left", 0)
  48.         sleep(0.7)
  49.         rs.setBundledOutput("left", ds)
  50.         sleep(0.7)
  51.         rs.setBundledOutput("left", 0)
  52.         term.clear()
  53.         print("Moved ", i, " out of ", nTimes, " blocks.")
  54.     end
  55. end
  56.  
  57. function moveWest(nTimes)
  58.     for i = 1, nTimes , 0.7 do
  59.         rs.setBundledOutput("left", dw)
  60.         sleep(0.7)
  61.         rs.setBundledOutput("left", 0)
  62.         sleep(0.7)
  63.         rs.setBundledOutput("left", dw)
  64.         sleep(0.7)
  65.         rs.setBundledOutput("left", 0)
  66.         term.clear()
  67.         print("Moved ", i, " out of ", nTimes, " blocks.")
  68.     end
  69. end
  70.  
  71. function movement()
  72.     term.clear()
  73.     while true do
  74.         print("What direction do you want to move?")
  75.         print("The platform will move", dm, " blocks in that direction.")
  76.         print("Use (n) for North")
  77.         print("Use (e) for East")
  78.         print("Use (s) for South")
  79.         print("Use (w) for West")
  80.         print("Use (q) to Exit")
  81.  
  82.         direction = io.read()
  83.         if direction == "n" then
  84.             moveNorth(dm)
  85.         else
  86.             if direction == "e" then
  87.                 moveEast(dm)
  88.             else
  89.                 if direction == "s" then
  90.                     moveSouth(dm)
  91.                 else
  92.                     if direction == "w" then
  93.                         moveWest(dm)
  94.                     else
  95.                         if direction == "q" then
  96.                             break
  97.                         else
  98.                             print("Wrong choice")
  99.                         end
  100.                     end
  101.                 end
  102.             end            
  103.         end
  104.     end
  105. end
  106.  
  107. movement()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement