8 posts
Posted 12 October 2012 - 05:17 PM
function Attack()
for i = 1,3 do
if not turtle.attack() then
turtle.forward()
end
end
function MoveAttackLeft()
Attack()
Turtle.left()
turtle.forward()
turtle.left()
end
end
MoveAttack()
MoveAttack()
MoveAttack()
function MoveAttackRight()
Attack()
turtle.right()
turtle.forward()
turtle.right()
end
the error is: "mobtrap:17: attempt to call nil
anyone know what the problem is, I would appreciate it :)/>/>
(I am new to computers)
818 posts
Posted 12 October 2012 - 05:24 PM
Where are you declaraing the function MoveAttack?
8 posts
Posted 12 October 2012 - 05:27 PM
Where are you declaraing the function MoveAttack?
very good question :)/>/>
I changed the name without changing the code :)/>/>
function Attack()
for i = 1,3 do
if not turtle.attack() then
turtle.forward()
end
end
function MoveAttackLeft()
Attack()
Turtle.left()
turtle.forward()
turtle.left()
end
end
MoveAttackLeft(3)
function MoveAttackRight()
Attack()
turtle.right()
turtle.forward()
turtle.right()
end
MoveAttackRight(3)
end
end
changed the code a little,now I get: " bios:206: [String "mobtrap"]:30: '<eof> ' expected
818 posts
Posted 12 October 2012 - 05:29 PM
Then I know I'm not the only one dumb enough to do stuff like that :)/>/>
8 posts
Posted 12 October 2012 - 05:34 PM
Then I know I'm not the only one dumb enough to do stuff like that :)/>/>
incase you didn't notice, I updated the reply if you can help me more :)/>/>
818 posts
Posted 12 October 2012 - 05:37 PM
'<eof>' expected means you have 1 too many ends :)/>/>
8 posts
Posted 12 October 2012 - 05:39 PM
'<eof>' expected means you have 1 too many ends :)/>/>
yes, I know, but where? :)/>/>
818 posts
Posted 12 October 2012 - 05:44 PM
plus, you didn't make your MoveAttackLeft() funciton accept arguments, so putting a 3 in there does nothing. change your MoveAttackLeft() funciton to something like this:
function MoveAttackLeft(times)
for i=1,times
Attack()
turtle.left()
turtle.forward()
turtle.left()
end
end
818 posts
Posted 12 October 2012 - 05:48 PM
wow ends are messed up in your code, I'll fix it…..
function Attack()
for i = 1,3 do
if not turtle.attack() then
turtle.forward()
end
end
end
function MoveAttackLeft(times)
for i=1,times
Attack()
turtle.left()
turtle.forward()
turtle.left()
end
end
MoveAttackLeft(3)
function MoveAttackRight(times)
for i=1,times
Attack()
turtle.right()
turtle.forward()
turtle.right()
end
end
8543 posts
Posted 12 October 2012 - 05:52 PM
function Attack()
for i = 1,3 do
if not turtle.attack() then
turtle.forward()
end
end
end
function MoveAttackLeft()
Attack()
turtle.left()
turtle.forward()
turtle.left()
end
MoveAttackLeft()
function MoveAttackRight()
Attack()
turtle.right()
turtle.forward()
turtle.right()
end
MoveAttackRight()
Corrected code. Removed the arguments to function calls that don't take arguments. Notice how it is easy to tell where you need end statements when you use proper indentation.
8 posts
Posted 12 October 2012 - 05:57 PM
Thanks :)/>/>
818 posts
Posted 12 October 2012 - 06:05 PM
Get Ninja'd, Lyqyd! Because it matters, yes.