Advertisement
TheRockettek

Untitled

Jan 3rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function surface()
  2. while turtle.detect() do
  3. turtle.up()
  4. end
  5. end
  6.  
  7. local function getBelowName()
  8. present,tile = turtle.inspectDown()
  9. if present then
  10. return tile.name
  11. end
  12. end
  13.  
  14. local function getBelowNameRaw(name)
  15. name = name or getBelowName()
  16. return string.sub(name,string.find(name,":")+1,#name)
  17. end
  18.  
  19. local function getItemSlotName(id)
  20. turtle.select(id)
  21. slot = turtle.getItemDetail()
  22. return slot.name
  23. end
  24.  
  25. deniedblocks = {"minecraft:dirt","minecraft:cobblestone","minecraft:stone"}
  26.  
  27. print("Starting...")
  28.  
  29. while true do
  30. surface()
  31. turtle.forward()
  32. if turtle.detectDown() then
  33. blockbelow = getBelowName()
  34. else
  35. blockbelow = "minecraft:air"
  36. end
  37. while getBelowNameRaw(blockbelow) ~= "minecraft:bedrock" do
  38. if blockbelow == "minecraft:lava" or blockbelow == "minecraft:flowing_lava" then
  39. turtle.select(1)
  40. turtle.place()
  41. turtle.refuel()
  42. print("Refueled. Fuel level now " .. turtle.getFuelLevel())
  43. else
  44. turtle.digDown()
  45. end
  46. for i=1,16,1 do
  47. if turtle.getItemCount(i) > 0 then
  48. slotname = getItemSlotName(i)
  49. for j=1,#deniedblocks,1 do
  50. if slotname == deniedblocks[j] then
  51. print("Slot " .. i .. " has denied block (" .. slotname .. "). Ejecting...")
  52. turtle.dropUp()
  53. end
  54. end
  55. end
  56. end
  57. turtle.down()
  58. end
  59. print("Layer done!")
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement