Advertisement
loepie

moving platform

May 11th, 2013
48
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.         Print("Moved " + i + " out of " + dm + " blocks.")
  25.     end
  26. end
  27.  
  28. function moveEast(nTimes)
  29.     for i = 1, nTimes , 0.7 do
  30.         rs.setBundledOutput("left", de)
  31.         sleep(0.7)
  32.         rs.setBundledOutput("left", 0)
  33.         sleep(0.7)
  34.         rs.setBundledOutput("left", de)
  35.         sleep(0.7)
  36.         rs.setBundledOutput("left", 0)
  37.         Print("Moved " + i + " out of " + dm + " blocks.")
  38.     end
  39. end
  40.  
  41. function moveSouth(nTimes)
  42.     for i = 1, nTimes , 0.7 do
  43.         rs.setBundledOutput("left", ds)
  44.         sleep(0.7)
  45.         rs.setBundledOutput("left", 0)
  46.         sleep(0.7)
  47.         rs.setBundledOutput("left", ds)
  48.         sleep(0.7)
  49.         rs.setBundledOutput("left", 0)
  50.         Print("Moved " + i + " out of " + dm + " blocks.")
  51.     end
  52. end
  53.  
  54. function moveWest(nTimes)
  55.     for i = 1, nTimes , 0.7 do
  56.         rs.setBundledOutput("left", dw)
  57.         sleep(0.7)
  58.         rs.setBundledOutput("left", 0)
  59.         sleep(0.7)
  60.         rs.setBundledOutput("left", dw)
  61.         sleep(0.7)
  62.         rs.setBundledOutput("left", 0)
  63.         Print("Moved " + i + " out of " + dm + " blocks.")
  64.     end
  65. end
  66.  
  67. function movement()
  68.     term.clear()
  69.     while true do
  70.         print("What direction do you want to move?")
  71.         print("The platform will move" + dm + " blocks in that direction.")
  72.         print("Use (n) for North")
  73.         print("Use (e) for East")
  74.         print("Use (s) for South")
  75.         print("Use (w) for West")
  76.         print("Use (q) to Exit")
  77.  
  78.         direction = io.read()
  79.         if direction == "n" then
  80.             moveNorth(dm)
  81.         else
  82.             if direction == "e" then
  83.                 moveEast(dm)
  84.             else
  85.                 if direction == "s" then
  86.                     moveSouth(dm)
  87.                 else
  88.                     if direction == "w" then
  89.                         moveWest(dm)
  90.                     else
  91.                         if direction == "q" then
  92.                             break
  93.                         else
  94.                             print("Wrong choice")
  95.                         end
  96.                     end
  97.                 end
  98.             end            
  99.         end
  100.     end
  101. end
  102.  
  103. movement()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement