kreezxil

Turtlescript Dump Command

Jul 23rd, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. --[[
  2. ======================= A KreezCo Production =============================
  3. == Written by: Kreezxil ==
  4. == Orignal Code by: M_I_Z_E ==
  5. == Many Parts of this code was barrowed from the original turtle ==
  6. == programs that come with computer craft. ==
  7. == http://www.computercraft.info/ ==
  8. == YouTube channel Name: Adventures in Casual Gaming ==
  9. == URL: http://www.youtube.com/user/kreezxil ==
  10. == Original URL: http://www.youtube.com/user/MIZ3craft ==
  11. == Please link to my channel and give proper credit if using my code. ==
  12. == Thanks for watching! ==
  13. == Created 6/25/2014 ==
  14. ==========================================================================
  15. --]]
  16.  
  17. --[[ Begin Library
  18. Libary by Kreezxil 7/29/2013
  19. --]]
  20.  
  21.  
  22. function dump(direction, slot)
  23. if slot == "all" then
  24. for i=1,16 do
  25. turtle.select(i)
  26. turtle.drop()
  27. end
  28. return
  29. end
  30.  
  31. turtle.select(slot)
  32. if direction == "f" then
  33. turtle.drop()
  34. elseif direction == "u" then
  35. turtle.dropUp()
  36. elseif direction == "d" then
  37. turtle.dropDown()
  38. end
  39. end
  40.  
  41. --[[ End Library --]]
  42.  
  43. local tArgs = { ... }
  44. --[[ test how many args were passed, if none set dist to 0 and assume
  45. forward facing. --]]
  46. if #tArgs < 2 then
  47. --[[ print usage --]]
  48. print("Usage: dump <dir> <slot>")
  49. print()
  50. return
  51. end
  52.  
  53. if string.find("fdu",tArgs[1]) ~= nil then
  54. direction = tArgs[1]
  55. else
  56. print("Error: Direction must be one of up, down, forward")
  57. return
  58. end
  59.  
  60. slot = tArgs[2]
  61. if slot ~= "all" then
  62. slot = tonumber(slot)
  63. if slot<1 or slot>16 then
  64. print("Error: Slot must be in the range 1 to 16 or 'all'")
  65. return
  66. end
  67. end
  68.  
  69. dump(direction,slot)
Add Comment
Please, Sign In to add comment