Jump to content




turtle mob grinder

turtle

  • You cannot reply to this topic
10 replies to this topic

#1 tribalthomas

  • Members
  • 12 posts

Posted 14 February 2013 - 05:21 AM

im making a mob grinder using turtles, but i cant get my program to work

while true do
turtle.attack()
sleep(2)
end

can anyone tell my what i did wrong

#2 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

Posted 14 February 2013 - 05:23 AM

What error are you getting and are you using a melee turtle?

#3 tribalthomas

  • Members
  • 12 posts

Posted 14 February 2013 - 05:25 AM

im not getting a error the turtle just isnt attacking

yes im using a melee turtle

#4 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 14 February 2013 - 05:35 AM

The turtle only actually swings its sword if there's something to attack in front of it.

#5 tribalthomas

  • Members
  • 12 posts

Posted 14 February 2013 - 05:43 AM

i changed the code alittle
while true do
  while turtle.detectDown() = true do
    turtle.attack()
  end
end

now it says

[string "startup"]:2: 'do' expected

any ideas on how to fix it

#6 Viproz

  • Members
  • 58 posts

Posted 14 February 2013 - 07:03 AM

View Posttribalthomas, on 14 February 2013 - 05:43 AM, said:

i changed the code alittle
while true do
  while turtle.detectDown() = true do
	turtle.attack()
  end
end

now it says

[string "startup"]:2: 'do' expected

any ideas on how to fix it

to compare two objects, you need to put "==" and not "=" so :
while true do
  while turtle.detectDown() == true do
	turtle.attack()
  end
end

But you don't need to put this, just do :
while true do
  while turtle.detectDown() do
	turtle.attack()
  end
end

Edit : the turtle.detectDown() func only return true when there is a block down

#7 mrbaconbitts

  • Members
  • 5 posts

Posted 14 February 2013 - 11:35 AM

All you need to have is

while true do
	 turtle.attack()
end

This will have your turtle attack only when there is a mob/person on the block directly in front of it. The sleep you have in your original code in unnecessary.

#8 Skullblade

  • Members
  • 470 posts
  • LocationThe Big Apple, NY

Posted 15 February 2013 - 01:39 AM

View Postmrbaconbitts, on 14 February 2013 - 11:35 AM, said:

All you need to have is

while true do
	 turtle.attack()
end

This will have your turtle attack only when there is a mob/person on the block directly in front of it. The sleep you have in your original code in unnecessary.
U need the sleep or it will error

#9 Doyle3694

  • Members
  • 815 posts

Posted 15 February 2013 - 01:40 AM

No it won't. Turtle functions yield.

#10 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 15 February 2013 - 01:42 AM

View PostDoyle3694, on 15 February 2013 - 01:40 AM, said:

No it won't. Turtle functions yield.
Only some turtle functions yield. but yes you are correct in this instance, this one yields.

#11 Ninjarhh

  • Members
  • 7 posts

Posted 15 February 2013 - 06:46 AM

In my opinion you should put a pressure plate infront on the turtle and do
while true do
    if redstone.getInput("front") then
	    turtle.attack()
    else
	    os.pullEvent("redstone")
    end
end
Viva la efficient coding ;P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users