Advertisement
soee

ladder

Sep 22nd, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --file:ladder
  2. --pastebin:wc6RNHeV
  3.  
  4. targs = {...}
  5. os.loadAPI("movement")
  6.  
  7. local m = movement
  8. local ladderSlot = 1
  9. local wallSlot = 2
  10. m.reservedslots = 2
  11.  
  12.  
  13. if ( #targs ~= 2 ) then
  14.     print("Usage : ladder <up|down> <count>")
  15.     print("Slot 1 : Ladders.")
  16.     print("Slot 2 : Walls")
  17.     return
  18. end
  19.  
  20. local direction = targs[1]
  21. local count = tonumber(targs[2])
  22.  
  23. if (turtle.getItemCount(ladderSlot)< count) then
  24.     print("not enough ladders in slot 1.")
  25.     return
  26. end
  27.  
  28. if (turtle.getItemCount(wallSlot)< count) then
  29.     print("not enough walls in slot 2.")
  30.     return
  31. end
  32.  
  33.  
  34. for i=1,count do
  35.     m.turtleForward()
  36.     m.paintForward(wallSlot)
  37.     turtle.back()
  38.     m.selectMaterial(ladderSlot)
  39.     turtle.place()
  40.     if direction == "up" then
  41.         m.turtleUp()
  42.     else
  43.         m.turtleDown()
  44.     end
  45. end
  46.  
  47. -- return
  48. for i=1,count do
  49.     if direction == "up" then
  50.         m.turtleDown()
  51.     else
  52.         m.turtleUp()
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement