Advertisement
TechManDylan

CreateCasingMaker1.2

Oct 25th, 2023 (edited)
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. -- List of Minecraft log types
  2. local logTypes = {
  3.     "minecraft:oak_log",
  4.     "minecraft:spruce_log",
  5.     "minecraft:birch_log",
  6.     "minecraft:jungle_log",
  7.     "minecraft:acacia_log",
  8.     "minecraft:dark_oak_log",
  9.     "biomesoplenty:fir_log",
  10.     "biomesoplenty:redwood_log",
  11.     "biomesoplenty:cherry_log",
  12.     "biomesoplenty:mahogany_log",
  13.     "biomesoplenty:jacaranda_log",
  14.     "biomesoplenty:palm_log",
  15.     "biomesoplenty:willow_log",
  16.     "biomesoplenty:dead_log",
  17.     "biomesoplenty:magic_log",
  18.     "biomesoplenty:umbran_log",
  19.     "biomesoplenty:hellbark_log"
  20. }
  21. -- List of Create casing types
  22. local casingTypes = {
  23.     "create:brass_casing",
  24.     "create:andesite_casing",
  25.     "create:copper_casing"
  26. }
  27.  
  28. -- Function to check if the block matches any of the specified casing types
  29. local function isCasingTypeInList(casingType)
  30.     for _, type in ipairs(casingTypes) do
  31.         if casingType == type then
  32.             return true
  33.         end
  34.     end
  35.     return false
  36. end
  37.  
  38. -- Check for turtle inventory for logs
  39. function checkInventoryForLogs()
  40.     for slot = 1, 16 do
  41.         local item = turtle.getItemDetail(slot)
  42.         if item and isLog(item.name) then
  43.             return slot
  44.         end
  45.     end
  46.     return nil
  47. end
  48.  
  49. -- Check if a given item name is a log
  50. function isLog(itemName)
  51.     for _, logType in ipairs(logTypes) do
  52.         if itemName == logType then
  53.             return true
  54.         end
  55.     end
  56.     return false
  57. end
  58.  
  59. -- Check if the block in front of the turtle is a casing and break it
  60. function checkAndBreakBlock()
  61.     local success, block = turtle.inspect()
  62.     if success and isCasingTypeInList(block.name) then
  63.         turtle.dig()
  64.         while turtle.detect() do
  65.             sleep(0.1)
  66.         end
  67.     end
  68. end
  69.  
  70. -- Place a log in front of the turtle
  71. function placeLog()
  72.     local slot = checkInventoryForLogs()
  73.     if slot then
  74.         turtle.select(slot)
  75.         turtle.place()
  76.         sleep(0.1)
  77.     end
  78. end
  79.  
  80. -- Print instructions to the player and clear the screen
  81. function printInstructions()
  82.     term.clear()
  83.     term.setCursorPos(1, 1)
  84.     print("Instructions:")
  85.     print("")
  86.     print("1. Fill the turtle's inventory with your logs of choice.")
  87.     print("")
  88.     print("2. Hold Brass, Copper, or Andesite alloy in offhand and an axe in main hand.")
  89.     print("")
  90.     print("3. Just hold right-click to make casings.")
  91. end
  92.  
  93. -- Print instructions once
  94. printInstructions()
  95.  
  96. -- Main loop
  97. while true do
  98.     placeLog()
  99.     checkAndBreakBlock()
  100.     sleep(0.1)
  101. end
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement