Turtles don't work

  • 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

Kaufman1

New Member
Jul 29, 2019
11
0
0
Need help with turtles. Walk me through how to make a melee turtle attack everything and deposit stuff into a chest below it.


This is what I found on the forums, I type in and it doesn't work. Help

__________
whiletruedo turtle.attack()end
This will make the turtle attack everything in front of it (including you!) endlessly, you have to terminate it by holding ctrl+T if you want to end the program. Fill the turtles inventory with cobblestone and it wont be able to pick up items.

If you want it to pick up items and drop it into a chest directly below the turtle, use this:

whiletruedo turtle.attack() i = turtle.getItemCount(16)if i ==64thenfor j=1,16do turtle.select(j) turtle.drop()end turtle.select(1)endend

_____

Thanks
 

budge

New Member
Jul 29, 2019
273
0
0
Well for starters, you need spaces between words. "while true do" and "turtle.attack() end". Secondly, that loop will time out after a few seconds with a "too long without yielding" error. Easiest fix is to add "sleep(0.5)" just before "end". It also helps readability if you use multiple lines (I think this is what Lambert was implying). Lastly, I'd suggest changing the first If statement to check for at least 1 item in slot 16. That way a bow in slot 16 won't break the code's functionality.

I've taken the second line of code you posted and made it more legible, changed the if statement for non-stackables, and applied the "sleep(0.5)" code to prevent yielding errors.
Code:
while true do
  turtle.attack()
  i = turtle.getItemCount(16)
  if i > 0 then
    for j = 1,16 do
      turtle.select(j)
      turtle.dropDown()
    end
    turtle.select(1)
  end
  sleep(0.5)
end

Edit: applied Fuzzlewhumper's fix
 
  • Like
Reactions: Lambert2191

Eyamaz

New Member
Jul 29, 2019
2,373
0
0
I always giggle like I'm 5 whenever I turtle.suck().

:p

Sent from my HTC One X+ using Tapatalk 2
 

Lambert2191

New Member
Jul 29, 2019
3,265
0
0
tutle.goDown()
edit: I was gonna edit that ^ but I thought I'd leave it in and point out that I know very well how to write turtle, but it is a word that I typo so often that the last program I wrote (I write pretty basic programs that just have a lot of lines) I had to correct "tutle" to "turtle" 15 times. Fuck my life...
 
  • Like
Reactions: Eyamaz