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

Wont Move!

Started by yuvrajkhosa, 06 August 2015 - 01:42 AM
yuvrajkhosa #1
Posted 06 August 2015 - 03:42 AM
Hi! I am very very new to LUA! and Computer Craft. I Tried to make a turtle That Go's turns and comes back. But it wont Move. its all fueled up too.
Heres the Code i wrote.



function Dig()
turtle.dig()
end
function Move()

for i = 1, 30 do
if not turtle.forward() then
Dig()
end
end
function turn()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end

end
Bomb Bloke #2
Posted 06 August 2015 - 07:40 AM
Know how you've got a "Dig()" function, which is called by "Move()"? The question is - where do you call "Move()"?

You've also got your "turn()" function declaration sitting inside the "Move()" declaration.
LuckyLuke #3
Posted 06 August 2015 - 09:43 AM
Try this:

-- Functions
function Move()
  for i = 1, 30 do
	  if not turtle.forward() then
	  turtle.dig()
	end
  end
end

function turn()
  turtle.turnRight()
  turtle.forward()
  turtle.turnRight()
end

-- Programm
Move()
turn()
Move()
Edited on 06 August 2015 - 07:45 AM