Melee Turtle Programming

  • 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

Sionyn

New Member
Jul 29, 2019
57
0
0
The program I'm using is:
while true do
turtle.attack()
sleep(0.1)
end
It isn't attacking the mobs that come's in-front of it. The mob is a Wither Skelly. Anyone know whats wrong? I'm on the ftb unleashed 1.1.7 pack.
 

Platinawolf

New Member
Jul 29, 2019
147
0
0
Screenshots? Does the code toss any errors? Does it attack you if you stand in front of it?

CC computers and turtles will only run their program until they are unloaded so you might want to save that program as startup to make sure that the turtle will resume its bashing duties if it happens to be unloaded.

Unloading happens if: Chunk turtle is in gets unloaded
Server restart.
Quitting a singleplayer world.
 

Neirin

New Member
Jul 29, 2019
590
0
0
The code should work, so I have to assume that the program isn't running. Like Platinawolf said, save the program as "startup" and reboot it.
 

Bomb Bloke

New Member
Jul 29, 2019
612
0
0
If you're using a permissions-based plugin it may interfere - the code'll run, but the turtle won't attack. PermissionsEx is probably the most common culprit.
 

Saice

New Member
Jul 29, 2019
4,020
0
1
I edit Startup and use
Code:
while true do
   while redstone.getInput("back") do
      turtle.attack()
      sleep(.1)
   end
sleep(.5)
end


The turtles sometimes derp out. They seem to work better with redstone toggles because it forces it to check for the signal and you can flip it on and off to reset it if it gets really derpy. You can change "back" to what ever side you want as long as there is leaver or something there.
 

rhn

Too Much Free Time
Nov 11, 2013
5,706
4,420
333
If you want it to automatically handle loot aswell you can use this:
http://pastebin.com/nRYFDYNg
Pretty simple, attack 1000 times, dump all 16 inventory slots, repeat.
And as Platina mentioned, name it startup. Can become rather problematic if you go away a sec while an mobfarm is running :p
 

Succubism

New Member
Jul 29, 2019
2,181
0
0
Here's a nice one for you. I use this for it's easy toggle-ability with a piston.

Code:
while true do
  while turtle.detectDown() ~= true do
    turtle.attack()
  end
end

Turtle will look for a block underneath it. If a block is present it won't attack. If block isn't present, it will attack if an entity's in range.
 

Platinawolf

New Member
Jul 29, 2019
147
0
0
Here's a nice one for you. I use this for it's easy toggle-ability with a piston.

Code:
while true do
  while turtle.detectDown() ~= true do
    turtle.attack()
  end
end

Turtle will look for a block underneath it. If a block is present it won't attack. If block isn't present, it will attack if an entity's in range.


That script will die due to never yielding, as every branch of the program needs a sleep, doesn't really matter how long, else the CC OS will kill the program for not yielding. If not someone could write a program that does
while true do
I=1
I=2
End

That simple little program would tie up CC utterly and totally without safeguards.


Sent from my iPad using Tapatalk
 

rhn

Too Much Free Time
Nov 11, 2013
5,706
4,420
333
That script will die due to never yielding, as every branch of the program needs a sleep, doesn't really matter how long, else the CC OS will kill the program for not yielding. If not someone could write a program that does
while true do
I=1
I=2
End

That simple little program would tie up CC utterly and totally without safeguards.


Sent from my iPad using Tapatalk
Yeah from what I can gather the turtle.attack() contain its own yield. But if the if the while condition is not met? Does the while condition contain a yield too? Nevertheless you should add a sleep() in the outer loop, if for nothing else to prevent spending a lot of resources on just checking condition for that while loop. You really don't need to look for a block under the turtle as often as the processor can handle. every couple of seconds should be plenty.