kreezxil

Untitled

May 9th, 2026
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.51 KB | Gaming | 0 0
  1. -- =============================================
  2. -- bMobFarm Optimized v2.1 - Full Featured
  3. -- For ComputerCraft 1.12.2
  4. -- =============================================
  5.  
  6. local VERSION = "v2.1"
  7.  
  8. -- ====================== CONFIG ======================
  9. local DROP_SHAFT_HEIGHT = 23
  10. local LADDER_ENABLED = true          -- will use slot 14 for ladders + balcony
  11. local CHEST_BEHIND = false           -- detected automatically
  12.  
  13. -- Slot layout (same as original for compatibility)
  14. local SLOT = {
  15.     mainBlock = 1,   -- cobble / obsidian
  16.     earlyBlock = 2,  -- sometimes different
  17.     spawnBlock = 6,  -- inner spawning floor
  18.     water1    = 12,
  19.     water2    = 13,
  20.     ladder    = 14,
  21.     special   = 15,  -- extra for ladders or decoration
  22.     torch     = 16,
  23.     faceMouth = 10,  -- for emoji (cobble replacement)
  24.     faceEyes  = 11   -- for emoji
  25. }
  26.  
  27. -- ====================== HELPER FUNCTIONS ======================
  28. local function tryForward() while not turtle.forward() do turtle.dig() end end
  29. local function tryUp()      while not turtle.up()      do turtle.digUp() end end
  30. local function tryDown()    while not turtle.down()    do turtle.digDown() end end
  31. local function tryBack()    while not turtle.back()    do turtle.dig() end end
  32.  
  33. local function select(slot) turtle.select(slot) end
  34. local function place()      turtle.place() end
  35. local function placeDown()  turtle.placeDown() end
  36. local function placeUp()    turtle.placeUp() end
  37. local function dig()        turtle.dig() end
  38.  
  39. local function turnLeft()   turtle.turnLeft() end
  40. local function turnRight()  turtle.turnRight() end
  41. local function turnAround()
  42.     turnRight(); turnRight()
  43. end
  44.  
  45. local function go(n, dir)
  46.     for i = 1, n do
  47.         if dir == "forward" then tryForward()
  48.         elseif dir == "back" then tryBack()
  49.         elseif dir == "up" then tryUp()
  50.         elseif dir == "down" then tryDown()
  51.         end
  52.     end
  53. end
  54.  
  55. local function refillFromChest()
  56.     if not CHEST_BEHIND then return end
  57.     print("Refilling from chest behind...")
  58.     turnAround()
  59.     for slot = 1, 16 do
  60.         if turtle.getItemCount(slot) == 0 or turtle.getItemCount(slot) < 32 then
  61.             select(slot)
  62.             while turtle.suck() do end
  63.         end
  64.     end
  65.     turnAround()
  66.     print("Refill complete.")
  67. end
  68.  
  69. -- ====================== SETUP PHASE ======================
  70. local function checkMaterials()
  71.     term.clear()
  72.     print("=== bMobFarm " .. VERSION .. " - Material Check ===")
  73.     print("Required slots (minimum stacks):")
  74.     print("  1-9 : Main blocks (cobble/obsidian) - ~8 stacks")
  75.     print(" 10-11: Face blocks (optional)")
  76.     print(" 12-13: Water buckets")
  77.     print(" 14   : Ladders (if enabled)")
  78.     print(" 15   : Extra blocks / ladders")
  79.     print(" 16   : Torches (~64)")
  80.     print("")
  81.  
  82.     local missing = false
  83.     for slot = 1, 16 do
  84.         local count = turtle.getItemCount(slot)
  85.         if slot <= 9 and count < 32 then
  86.             print("Slot " .. slot .. ": only " .. count .. " (need ~32+)")
  87.             missing = true
  88.         elseif slot == 16 and count < 16 then
  89.             print("Slot 16 (torches): only " .. count .. " (need 16+)")
  90.             missing = true
  91.         end
  92.     end
  93.  
  94.     if missing then
  95.         print("\nSome slots are low. Top up now or continue anyway?")
  96.     end
  97.  
  98.     print("\nIs a chest placed directly behind the turtle for refilling? (y/n)")
  99.     local ans = read():lower()
  100.     CHEST_BEHIND = (ans == "y")
  101.  
  102.     if CHEST_BEHIND then
  103.         refillFromChest()
  104.     end
  105.  
  106.     print("\nPress ENTER to START build")
  107.     print("or type 'abort' to cancel now")
  108.     local input = read():lower()
  109.     if input == "abort" then
  110.         print("Build aborted by user.")
  111.         return false
  112.     end
  113.     return true
  114. end
  115.  
  116. -- ====================== ROOF EMOJI MENU ======================
  117. local function chooseRoofEmoji()
  118.     term.clear()
  119.     print("=== Roof Emoji Options (top popular designs) ===")
  120.     print("These fit perfectly on the 9x9 roof:")
  121.     print("  0. Plain roof (no emoji)")
  122.     print("  1. Creeper Face (classic)")
  123.     print("  2. Smiley Face :)")
  124.     print("  3. Evil Grin >:)")
  125.     print("  4. Heart <3")
  126.     print("  5. Skull")
  127.     print("  6. Star")
  128.     print("  7. Peace Sign")
  129.     print("  8. Diamond")
  130.     print("  9. TNT")
  131.     print(" 10. Steve Face")
  132.     print("\n(Only 1-4 are fully implemented with custom blocks.")
  133.     print("Higher numbers will use Creeper style with your face blocks.)")
  134.     print("Enter number (0-10): ")
  135.     local choice = tonumber(read()) or 0
  136.     if choice < 0 or choice > 10 then choice = 0 end
  137.     print("Selected: " .. (choice == 0 and "Plain roof" or "Emoji #" .. choice))
  138.     return choice
  139. end
  140.  
  141. local function buildRoofEmoji(choice)
  142.     print("Building roof + emoji #" .. choice)
  143.  
  144.     -- Flat 9x9 roof base
  145.     select(SLOT.mainBlock)
  146.     for _ = 1, 4 do
  147.         for i = 1, 8 do tryForward(); place() end
  148.         turnRight()
  149.     end
  150.  
  151.     -- Place torches on roof edges to prevent spawning
  152.     select(SLOT.torch)
  153.     turnAround()
  154.     for i = 1, 8 do tryForward() end
  155.     for side = 1, 4 do
  156.         for i = 1, 8 do
  157.             placeUp()
  158.             tryForward()
  159.         end
  160.         turnRight()
  161.     end
  162.     turnAround() -- back to center-ish
  163.  
  164.     -- Emoji drawing (simple patterns using face slots)
  165.     if choice == 0 then
  166.         -- plain, already done
  167.         return
  168.     end
  169.  
  170.     select(choice <= 4 and SLOT.faceEyes or SLOT.faceMouth)
  171.  
  172.     if choice == 1 or choice >= 5 then -- Creeper / default
  173.         -- Classic creeper face (eyes + mouth)
  174.         go(3, "forward"); turnLeft()
  175.         go(3, "forward")
  176.         place(); tryForward(); place()
  177.         go(2, "back"); turnRight(); turnRight()
  178.         go(3, "forward")
  179.         place(); tryForward(); place() -- eyes
  180.         go(2, "back"); turnRight()
  181.         go(4, "forward")
  182.         select(SLOT.faceMouth)
  183.         for i = 1, 3 do place(); tryForward() end -- mouth
  184.     elseif choice == 2 then -- Smiley :)
  185.         go(3, "forward"); turnLeft(); go(2, "forward")
  186.         place(); tryForward(); place() -- eyes
  187.         go(3, "back"); turnRight(); go(3, "forward")
  188.         select(SLOT.faceMouth)
  189.         place(); tryForward(); place(); tryForward(); place() -- curved mouth
  190.     elseif choice == 3 then -- Evil Grin
  191.         go(3, "forward"); turnLeft(); go(2, "forward")
  192.         place(); tryForward(); place() -- eyes
  193.         go(3, "back"); turnRight(); go(4, "forward")
  194.         select(SLOT.faceMouth)
  195.         place(); tryForward(); place(); tryForward(); place()
  196.     elseif choice == 4 then -- Heart
  197.         go(3, "forward"); turnLeft(); go(2, "forward")
  198.         place(); tryForward(); place()
  199.         go(1, "forward"); turnRight(); place()
  200.         turnRight(); place(); tryForward(); place()
  201.     end
  202.  
  203.     print("Roof + emoji complete with torches!")
  204. end
  205.  
  206. -- ====================== LADDER + BALCONY SYSTEM ======================
  207. local function buildLadderAndBalcony()
  208.     if not LADDER_ENABLED then return end
  209.     print("Building ladder column + roof balcony...")
  210.  
  211.     -- Move to side position for ladder column
  212.     turnLeft()
  213.     go(5, "forward")  -- outside the main 9x9
  214.     turnRight()
  215.  
  216.     -- Build vertical ladder all the way up (we're at top, so go down placing)
  217.     select(SLOT.ladder)
  218.     for i = 1, DROP_SHAFT_HEIGHT + 8 do  -- extra for safety
  219.         tryDown()
  220.         placeDown()
  221.     end
  222.  
  223.     -- Build small balcony at roof level
  224.     turnLeft()
  225.     go(2, "forward")
  226.     select(SLOT.mainBlock)
  227.     for i = 1, 3 do
  228.         placeDown()
  229.         tryForward()
  230.     end
  231.     turnRight()
  232.     for i = 1, 3 do
  233.         placeDown()
  234.         tryForward()
  235.     end
  236.  
  237.     print("Ladder column + balcony complete!")
  238.     -- Return turtle to safe spot
  239.     turnAround()
  240.     go(6, "forward")
  241.     turnLeft()
  242. end
  243.  
  244. -- ====================== MAIN BUILDING FUNCTIONS ======================
  245. local function buildDropShaft()
  246.     print("=== Building Drop Shaft (" .. DROP_SHAFT_HEIGHT .. " layers) ===")
  247.     for layer = 1, DROP_SHAFT_HEIGHT do
  248.         print("Drop shaft layer " .. layer .. "/" .. DROP_SHAFT_HEIGHT)
  249.         turnAround()
  250.  
  251.         local slot = (layer <= 2) and SLOT.earlyBlock or SLOT.mainBlock
  252.         select(slot)
  253.  
  254.         -- 9x9 layer with walls (optimized loop)
  255.         for _ = 1, 4 do
  256.             for i = 1, 8 do
  257.                 tryForward()
  258.                 place()
  259.             end
  260.             turnRight()
  261.         end
  262.  
  263.         -- Water on very first layer
  264.         if layer == 1 then
  265.             select(SLOT.water1)
  266.             go(4, "forward")
  267.             turnLeft()
  268.             place()
  269.             turnAround()
  270.             select(SLOT.water2)
  271.             place()
  272.             go(4, "forward")
  273.         end
  274.  
  275.         -- Occasional torch inside shaft
  276.         if layer % 6 == 0 then
  277.             select(SLOT.torch)
  278.             placeUp()
  279.         end
  280.  
  281.         if layer < DROP_SHAFT_HEIGHT then tryUp() end
  282.         refillFromChest() -- occasional top-up
  283.     end
  284.     print("Drop shaft finished!")
  285. end
  286.  
  287. local function buildSpawnArea(lowerHalf)
  288.     local layers = lowerHalf and 4 or 3
  289.     print("=== Building " .. (lowerHalf and "Lower" or "Upper") .. " Spawn Area (" .. layers .. " layers) ===")
  290.  
  291.     for i = 1, layers do
  292.         print("Spawn layer " .. i)
  293.         select(SLOT.mainBlock)
  294.  
  295.         -- Outer 9x9 platform
  296.         for _ = 1, 4 do
  297.             for j = 1, 8 do tryForward(); place() end
  298.             turnRight()
  299.         end
  300.  
  301.         -- Inner 7x7 spawning floor
  302.         go(1, "forward"); turnRight(); go(1, "forward")
  303.         select(SLOT.spawnBlock)
  304.         for _ = 1, 4 do
  305.             for j = 1, 6 do tryForward(); place() end
  306.             turnRight()
  307.         end
  308.  
  309.         if i < layers then tryUp() end
  310.         refillFromChest()
  311.     end
  312. end
  313.  
  314. -- ====================== MAIN PROGRAM ======================
  315. term.clear()
  316. print("=== bMobFarm Optimized " .. VERSION .. " by Grok ===")
  317. print("Mob farm tower builder with all your requested features")
  318.  
  319. if not checkMaterials() then return end
  320.  
  321. -- Build sequence
  322. buildDropShaft()
  323.  
  324. -- Reposition for spawn areas
  325. turnAround()
  326. go(8, "back")
  327. go(DROP_SHAFT_HEIGHT, "up")
  328. go(8, "back")
  329.  
  330. buildSpawnArea(true)   -- lower half
  331. buildSpawnArea(false)  -- upper half
  332.  
  333. -- Roof
  334. local emojiChoice = chooseRoofEmoji()
  335. buildRoofEmoji(emojiChoice)
  336.  
  337. -- Access system
  338. buildLadderAndBalcony()
  339.  
  340. print("\n=== BUILD COMPLETE! ===")
  341. print("Tower, drop shaft, spawn platforms, roof emoji, torches, ladder + balcony done.")
  342. print("You can now add the killing chamber below the drop shaft.")
  343. print("Enjoy your mob farm! :)")
Add Comment
Please, Sign In to add comment