Begineer turtle question

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Racer193

New Member
Jul 29, 2019
26
0
0
Hey im making a simple mob grinder and having the turtles pick it items and send it through pipes to a processor, but when im going to upgrade my mob grinder i will add another row of turtles to help kill mobs for a tier 5 spawner. So i need the items on the top turtle to get send to the turtle directly below it. Here is my code...

  1. local a = 0
  2. while a == 0 do
  3. while turtle.attack() == true do
  4. sleep(0.5)
  5. end
    end

Simle enough... i just need the drop down to the other turtles added and was woundering if someone could give me the code that will do this or write it for me and paste it? I appreciate all and any help
 

solidity

Active Member
Jul 29, 2019
53
0
26
I would suggest the following:
Code:
while true do
if turtle.attack() then
for s=1,16 do
turtle.select(s)
turtle.dropDown()
end
turtle.select(1)
end
sleep(1)
end

This will try to attack, if the attack is successful, it will go through all slots (you might have killed a mob which dropped more than one item) and drop them down. After that, it will sleep for a second and start over.
 

IBurn36360

Member
Jul 29, 2019
57
0
16
Code:
local sSide = "top" -- Our side that the mobs are on, can only be top, bottom and front for attack
local sleepTime = 30 -- Sleep time in server seconds
local dropOffSide = "front" -- Side to drop items into, can be top, front or bottom
 
while true do
  if (sSide == "top") then
    while (turtle.attackTop()) do
      turtle.attackTop() -- Attack while mobs are there until they all die
    end
  elseif  (sSide == "front") then
    while (turtle.attack()) do
      turtle.attack()
    end
  elseif (sSide == "bottom") then
    while (turtle.attackDown()) do
      turtle.attackDown()
    end
  else -- Default to up if the user made a mistake
    while (turtle.attackTop()) do
      turtle.attackTop()
    end
  end
 
  if (dropOffSide == "top") then
    for i = 1, 16, 1 do
      while not(turtle.dropUp()) do
        os.sleep(5)
      end
      turtle.dropUp()
    end
  elseif (dropOffSide == "front") then
    for i = 1, 16, 1 do
      while not(turtle.drop()) do
        os.sleep(5)
      end
      turtle.drop()
    end
  elseif (dropOffSide == "bottom") then
    for i = 1, 16, 1 do
      while not(turtle.dropDown()) do
        os.sleep(5)
      end
      turtle.dropDown()
    end
  else -- Tell the user where to put a chest
    print("Please place a chest on the "..dropOffSide.." side for dropoff")
    print("Please press enter to unfreeze")
    while true do
      local lEvent, lKey = os.pullEvent("key")
      if lEvent == "key" then
        if lKey == 28 then
          term.clear()
          term.setCursorPos(1, 1)
          break
        end
      end
    end
  end
 
  os.sleep(sleepTime)
end

Place this as a startup to make the turtle do this at all times

EDIT: Fixed top attack and added a check for the dropoff so we con't create items when dropoff fails. Effectively freezes the turtle if dropoff fails.