Advertisement
TechManDylan

CreateCasingMaker1.3

May 24th, 2025 (edited)
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. -- List of Create casing types
  2. local casingTypes = {
  3.     "create:brass_casing",
  4.     "create:andesite_casing",
  5.     "create:copper_casing"
  6. }
  7.  
  8. -- Function to check if the block matches any of the specified casing types
  9. local function isCasingTypeInList(casingType)
  10.     for _, type in ipairs(casingTypes) do
  11.         if casingType == type then
  12.             return true
  13.         end
  14.     end
  15.     return false
  16. end
  17.  
  18. -- Check if a given item name contains "log"
  19. function isLog(itemName)
  20.     return string.find(itemName, "log") ~= nil
  21. end
  22.  
  23. -- Check for turtle inventory for logs
  24. function checkInventoryForLogs()
  25.     for slot = 1, 16 do
  26.         local item = turtle.getItemDetail(slot)
  27.         if item and isLog(item.name) then
  28.             return slot
  29.         end
  30.     end
  31.     return nil
  32. end
  33.  
  34. -- Check if the block in front of the turtle is a casing and break it
  35. function checkAndBreakBlock()
  36.     local ok, success, block = pcall(turtle.inspect)
  37.  
  38.     if ok and success and block and isCasingTypeInList(block.name) then
  39.         turtle.dig()
  40.         while turtle.detect() do
  41.             sleep(0.1)
  42.         end
  43.     end
  44. end
  45.  
  46. -- Place a log in front of the turtle
  47. function placeLog()
  48.     local slot = checkInventoryForLogs()
  49.     if slot then
  50.         turtle.select(slot)
  51.         turtle.place()
  52.         sleep(0.1)
  53.     else
  54.         print("No logs in inventory!")
  55.         sleep(1)
  56.     end
  57. end
  58.  
  59. -- Print instructions to the player and clear the screen
  60. function printInstructions()
  61.     term.clear()
  62.     term.setCursorPos(1, 1)
  63.     print("Instructions:")
  64.     print("")
  65.     print("1. Fill the turtle's inventory with any logs (must have 'log' in the name).")
  66.     print("")
  67.     print("2. Hold Brass, Copper, or Andesite alloy in offhand and an axe in main hand.")
  68.     print("")
  69.     print("3. Just hold right-click to make casings.")
  70. end
  71.  
  72. -- Print instructions once
  73. printInstructions()
  74.  
  75. -- Main loop
  76. while true do
  77.     placeLog()
  78.     checkAndBreakBlock()
  79.     sleep(0.1)
  80. end
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement