This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mtshaw113's profile picture

Enderman Farming

Started by Mtshaw113, 01 February 2014 - 01:42 PM
Mtshaw113 #1
Posted 01 February 2014 - 02:42 PM
Ok so I got 2 melee turtles placed down ready to go, and I have no idea how to code. I thought I did it right, but it gives me <eof> expected on line 5
Program so far:
Spoiler

turtle.forward()
if turtle.forward()==false then
   turtle.attack()
   end
else
   turtle.forward(16)
   end
Basically its a 2 block wide stretch of glowstone, 17 blocks long, enderman fall and almost die, I need my turtle to go forward, if it cant, attack the enderman, and keep moving. Once its at the end, I need it to turn around, and come back, and then drop it in a chest behind it.
Thanks for any help!
Lyqyd #2
Posted 01 February 2014 - 05:12 PM
It's if / else / end, not if / end / else / end. Remove the end from just before the else and it should work fine. Be aware that turtle.forward(16) is still only going to move one block forward, since turtle movement command don't accept arguments.
awsmazinggenius #3
Posted 01 February 2014 - 05:50 PM
Based on Lyqyd's instruction, here is how it should be.

turtle.forward()
if turtle.forward() == false then
   turtle.attack()
else
   for i=1, 16 do
	   turtle.forward()
   end
end
Also, note that you can check for a block with turtle.detect() without actually moving forward.