Jump to content




Melee Turtle programs



8 replies to this topic

#1 PhilHibbs

  • Members
  • 98 posts

Posted 29 January 2013 - 04:07 AM

Has anyone done a program for a Melee Turtle? I've got a top-tier zombie spawner dropping into a 1x1 kill zone with a stone pressure plate to cut off the spawner and regulate the flow. All I need is a turtle that sits there and attacks, which I have, but it would be nice to be able to dump loot into a couple of chests (Rotten Flesh in one chest, all other loot in another). I'll have a go at it tonight if no-one's already done anything like this. At the moment my program is just this:

while 1 do
  if turtle.detect()
    turtle.attack()
  end
end

Should I introduce some kind of artificial delay such as sleep or yield in this to avoid CPU load?

#2 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 29 January 2013 - 04:49 AM

This is in the wrong section. Even though it's about programs, 'Ask a Pro' would be a better place to put this.

You're program has bad syntax, it's 'if turtle.detect() then'. But maybe you just mistyped. Besides that, I think that turtle.attack() does yield, so you don't have to put something else in there. (yielding isn't to avoid CPU load but to give other computers/programs a chance to run their code as well). Also, I don't believe that turtle.detect() returns true when the turtle has a mob in front of it (not 100% sure). You could really just have this:
while true do
  turtle.attack()
end


#3 PhilHibbs

  • Members
  • 98 posts

Posted 29 January 2013 - 05:39 AM

View PostOrwell, on 29 January 2013 - 04:49 AM, said:

This is in the wrong section. Even though it's about programs, 'Ask a Pro' would be a better place to put this.

You're program has bad syntax, it's 'if turtle.detect() then'. But maybe you just mistyped. Besides that, I think that turtle.attack() does yield, so you don't have to put something else in there. (yielding isn't to avoid CPU load but to give other computers/programs a chance to run their code as well). Also, I don't believe that turtle.detect() returns true when the turtle has a mob in front of it (not 100% sure). You could really just have this:
while true do
  turtle.attack()
end

You're right that I missed out the "then", I'm not at the computer where my scripts are right now. I did find that adding a turtle.detect() check seemed to improve framerate in the game when there were no mobs in front of the turtle. Might have been an illusion, but it seemed better not to have the sword swinging when there's nothing there.

#4 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 29 January 2013 - 05:43 AM

View PostPhilHibbs, on 29 January 2013 - 05:39 AM, said:

View PostOrwell, on 29 January 2013 - 04:49 AM, said:

This is in the wrong section. Even though it's about programs, 'Ask a Pro' would be a better place to put this.

You're program has bad syntax, it's 'if turtle.detect() then'. But maybe you just mistyped. Besides that, I think that turtle.attack() does yield, so you don't have to put something else in there. (yielding isn't to avoid CPU load but to give other computers/programs a chance to run their code as well). Also, I don't believe that turtle.detect() returns true when the turtle has a mob in front of it (not 100% sure). You could really just have this:
while true do
  turtle.attack()
end

You're right that I missed out the "then", I'm not at the computer where my scripts are right now. I did find that adding a turtle.detect() check seemed to improve framerate in the game when there were no mobs in front of the turtle. Might have been an illusion, but it seemed better not to have the sword swinging when there's nothing there.
It won't swing if there's nothing there; turtle.attack() returns false without swinging when there's no mob in range. As I said, I suspect that turtle.detect() doesn't even returns true when there's a mob in front of the turtle.

#5 PhilHibbs

  • Members
  • 98 posts

Posted 29 January 2013 - 06:51 AM

Odd. I'm sure saw it swinging away constantly with nothing there until I put in the detect check. I'll try again tonight.

#6 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 29 January 2013 - 07:50 AM

Moved to Ask a Pro.

#7 Frederikam

  • Members
  • 112 posts
  • LocationDenmark

Posted 29 January 2013 - 08:46 AM

To dump stuff down you can use:
turtle.dropDown()
Or in case you want it to drop forward:
turtle.drop()
Or have it drop the items up:
turtle.dropUp()
Putting one of these after turtle.attack() would be optimal.

#8 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 29 January 2013 - 09:05 AM

View PostFrederikam, on 29 January 2013 - 08:46 AM, said:

To dump stuff down you can use:
turtle.dropDown()
Or in case you want it to drop forward:
turtle.drop()
Or have it drop the items up:
turtle.dropUp()
Putting one of these after turtle.attack() would be optimal.
Optimal would be to dump the loot after the mob has been killed. Otherwise you'd kill the mob slower by dropping each item in between each blow.

#9 PhilHibbs

  • Members
  • 98 posts

Posted 29 January 2013 - 01:14 PM

I've made my script: http://www.computerc...ob-farm-script/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users