Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- List of Create casing types
- local casingTypes = {
- "create:brass_casing",
- "create:andesite_casing",
- "create:copper_casing"
- }
- -- Function to check if the block matches any of the specified casing types
- local function isCasingTypeInList(casingType)
- for _, type in ipairs(casingTypes) do
- if casingType == type then
- return true
- end
- end
- return false
- end
- -- Check if a given item name contains "log"
- function isLog(itemName)
- return string.find(itemName, "log") ~= nil
- end
- -- Check for turtle inventory for logs
- 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 the block in front of the turtle is a casing and break it
- function checkAndBreakBlock()
- local ok, success, block = pcall(turtle.inspect)
- if ok and success and block and isCasingTypeInList(block.name) then
- turtle.dig()
- while turtle.detect() do
- sleep(0.1)
- end
- end
- end
- -- Place a log in front of the turtle
- function placeLog()
- local slot = checkInventoryForLogs()
- if slot then
- turtle.select(slot)
- turtle.place()
- sleep(0.1)
- else
- print("No logs in inventory!")
- sleep(1)
- end
- end
- -- Print instructions to the player and clear the screen
- function printInstructions()
- term.clear()
- term.setCursorPos(1, 1)
- print("Instructions:")
- print("")
- print("1. Fill the turtle's inventory with any logs (must have 'log' in the name).")
- print("")
- print("2. Hold Brass, Copper, or Andesite alloy in offhand and an axe in main hand.")
- print("")
- print("3. Just hold right-click to make casings.")
- end
- -- Print instructions once
- printInstructions()
- -- Main loop
- while true do
- placeLog()
- checkAndBreakBlock()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement