Advertisement
kreezxil

Turtlescript Place Command

Jul 23rd, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 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 place(direction, slot)
  23. turtle.select(slot)
  24. if direction == "f" then
  25. turtle.place()
  26. elseif direction == "u" then
  27. turtle.placeUp()
  28. elseif direction == "d" then
  29. turtle.placeDown()
  30. end
  31. end
  32.  
  33. --[[ End Library --]]
  34.  
  35. local tArgs = { ... }
  36. --[[ test how many args were passed, if none set dist to 0 and assume
  37. forward facing. --]]
  38. if #tArgs < 2 then
  39. --[[ print usage --]]
  40. print("Usage: place <dir> <slot>")
  41. print()
  42. return
  43. end
  44.  
  45. if string.find("fdu",tArgs[1]) ~= nil then
  46. direction = tArgs[1]
  47. else
  48. print("Error: Direction must be one of up, down, forward")
  49. return
  50. end
  51.  
  52. slot = tArgs[2]
  53. if slot ~= "all" then
  54. slot = tonumber(slot)
  55. if slot<1 or slot>16 then
  56. print("Error: Slot must be in the range 1 to 16")
  57. return
  58. end
  59. end
  60.  
  61. place(direction,slot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement