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
1214 posts
Location
The Sammich Kingdom
Posted 14 February 2013 - 05:23 AM
What error are you getting and are you using a melee turtle?
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
1688 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.
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
57 posts
Posted 14 February 2013 - 07:03 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
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
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.
497 posts
Location
The Big Apple, NY
Posted 15 February 2013 - 01:39 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.
U need the sleep or it will error
818 posts
Posted 15 February 2013 - 01:40 AM
No it won't. Turtle functions yield.
7508 posts
Location
Australia
Posted 15 February 2013 - 01:42 AM
No it won't. Turtle functions yield.
Only some turtle functions yield. but yes you are correct in this instance, this one yields.
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