Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local result, message, item_name = 0
- local turtle_selected_spot = 1
- local block_present, info, item_count = 0
- print("Press CTRL+T to stop")
- while true do --Always loop
- if turtle_selected_spot == 17 then --No items left in turtle and since we do not have a 17th inventory spot this would cause an error so start back at slot 1
- turtle_selected_spot = 1
- turtle.select(turtle_selected_spot)
- item_details = turtle.getItemDetail(turtle_selected_spot)
- if item_details == nil then --No items in slot one so we are probably out of items to place
- block_present, info = turtle.inspect() --Check block in front of turtle to see if it needs to be mined before we quit the script
- if block_present and info.name ~= "minecraft:netherrack" then
- turtle.dig()
- end
- print("Turtle out of items.")
- return
- else
- if item_details.name ~= "minecraft:netherrack" then --The item in slot one is not netherrack so drop it then quit the script
- turtle.dropUp()
- block_present, info = turtle.inspect() --Check block in front of turtle to see if it needs to be mined before we quit the script
- if block_present and info.name ~= "minecraft:netherrack" then
- turtle.dig()
- end
- print("Turtle out of items.")
- return
- end
- end
- end
- turtle.select(turtle_selected_spot)
- turtle.suckDown() --Pull items from chest below turtle
- item_details = turtle.getItemDetail(turtle_selected_spot) --Get count and name of selected turtle inventory item
- if item_details == nil then --Turtle no longer has inventory in selected spot
- turtle_selected_spot = turtle_selected_spot + 1 --Move to next inventory spot
- end
- if item_details ~= nil then --If an item is in the selected slot then get details of that item
- if item_details.name ~= "minecraft:netherrack" then --If item is not netherrack then drop it above turtle
- turtle.dropUp()
- end
- if item_details.name == "minecraft:netherrack" then --If the item is netherrack then attempt to place in front of turtle
- --Scan block in front of turtle to see if it's empty
- block_present, info = turtle.inspect()
- if block_present and info.name ~= "minecraft:netherrack" then
- turtle.dig()
- end
- if block_present == false and item_details.name == "minecraft:netherrack" then
- turtle.place()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment