Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- List of Minecraft log types to strip
- local logTypes = {
- "minecraft:oak_log",
- "minecraft:spruce_log",
- "minecraft:birch_log",
- "minecraft:jungle_log",
- "minecraft:acacia_log",
- "minecraft:dark_oak_log",
- }
- -- Check for Minecraft logs in turtle inventory
- function checkInventoryForLogs()
- for slot = 1, 16 do
- local item = turtle.getItemDetail(slot)
- if item and isLog(item.name) then
- return slot
- end
- end
- return nil
- end
- -- Check if a given item name is a log
- function isLog(itemName)
- for _, logType in ipairs(logTypes) do
- if itemName == logType then
- return true
- end
- end
- return false
- end
- -- Check if the block in front of the turtle is a stripped log and break it
- function checkAndBreakBlock()
- local success, block = turtle.inspect()
- if success and isStrippedLog(block.name) then
- turtle.dig()
- while turtle.detect() do
- sleep(0.1)
- end
- end
- end
- -- Check if a given item name is a stripped log
- function isStrippedLog(blockName)
- return blockName:match("^minecraft:stripped_")
- end
- -- Place a stripped log in front of the turtle
- function placeLog()
- local slot = checkInventoryForLogs()
- if slot then
- turtle.select(slot)
- turtle.place()
- sleep(0.1)
- end
- end
- -- Main loop
- while true do
- placeLog()
- checkAndBreakBlock()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement