Jump to content




Wont Move!


2 replies to this topic

#1 yuvrajkhosa

  • New Members
  • 1 posts

Posted 06 August 2015 - 02: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

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 06 August 2015 - 06: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.

#3 LuckyLuke

  • Members
  • 52 posts
  • LocationMinecraft

Posted 06 August 2015 - 08: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 by LuckyLuke, 06 August 2015 - 08:45 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users