Advertisement
tahg

utils

Oct 19th, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. gfl = turtle.getFuelLevel
  2. local refuel(amount)
  3. local slot = turtle.select()
  4. if gfl() < amount) then
  5. for i = 1, 16 do
  6. while turtle.refuel() do
  7. if gfl() >= amount then
  8. turtle.select(slot)
  9. return true
  10. end
  11. end
  12. end
  13. end
  14. return false
  15. end
  16.  
  17. local forward()
  18. while not turtle.forward do
  19. if not refuel(1) then
  20. os.sleep(10)
  21. end
  22. end
  23. end
  24.  
  25. local back()
  26. while not turtle.back do
  27. os.sleep(10)
  28.  
  29. local tHandlers = {
  30. ["B"] = turtle.back,
  31. ["D"] = turtle.down,
  32. ["F"] = turtle.forward,
  33. ["L"] = turtle.turnLeft,
  34. ["O"] = turtle.placeUp,
  35. ["P"] = turtle.place,
  36. ["Q"] = turtle.placeDown,
  37. ["R"] = turtle.turnRight,
  38. ["U"] = turtle.up
  39. }
  40.  
  41. local function exec(command)
  42. if type(command) ~= "string" then return end
  43. for i = 1, #command do
  44. local cmd = tHandlers[command:sub(i,i)]
  45. if cmd then cmd() end
  46. end
  47. end
  48.  
  49. local function door(n)
  50. turtle.select(n)
  51. exec("BUQUQPLLPRBP")
  52. end
  53.  
  54. local function wall(n)
  55. turtle.select(n)
  56. exec("BPLLPUQ PLLPUQ PLLPRBP")
  57. end
  58.  
  59. local function corner(n)
  60. turtle.select(16)
  61. turtle.placeDown()
  62. turtle.select(n)
  63. exec("LFFRPDPDP")
  64. end
  65.  
  66. local function ladder()
  67. turtle.select(15)
  68. exec("BLFDQUQUQUQRFF")
  69. end
  70.  
  71. local function noladder()
  72. exec("UULFRF")
  73. end
  74.  
  75. local function ceiling(n)
  76. turtle.select(n)
  77. exec("QBQBQBQRFR QBQBQBQLFL QBQBQBQRFR QBQBQBQ")
  78. end
  79.  
  80. ceiling()
  81. os.exit()
  82.  
  83. turtle.forward()
  84. turtle.forward()
  85. turtle.forward()
  86. turtle.turnRight()
  87. door()
  88. corner()
  89. wall()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement