21 posts
Posted 21 September 2015 - 10:00 AM
I've made a small function in a program to make a turtle go forward till something is in front of it
function toWall()
while turtle.detect() == false do
turtle.forward()
end
end
toWall()
after running the program the turtle "freezes", it become unresponsive, and I can't type anything
I've done the same while loop outside of the function, in a different program and the same thing happens
209 posts
Location
Denmark
Posted 21 September 2015 - 10:05 AM
if i understand CC lua right..
thats is because when your loop ends, it calls the function again, and starts over..
that might be why it freezes..
i would remove the function and just have it as
while turtle.detect() == false do
turtle.forward()
end
that will exit the program when it detects something
You can also terminate a program by holding down CTRL + T
Edited on 21 September 2015 - 08:06 AM
21 posts
Posted 21 September 2015 - 10:11 AM
yes, i said I done the same while loop outside of the function in a different program and the same thing happened
209 posts
Location
Denmark
Posted 21 September 2015 - 10:14 AM
it stops fine when i run that code block
btw.. did you remember to fuel the turtle??
Edited on 21 September 2015 - 08:18 AM
21 posts
Posted 21 September 2015 - 10:18 AM
I tried CTRL+t but it done nothing
209 posts
Location
Denmark
Posted 21 September 2015 - 10:22 AM
sounds weird..
holding down ctrl + t for about 2 seconds should terminate any running program
but as said.. it works fine for me.
my best bet is that the turtle doesnt have any fuel in it, and therefor cant move
21 posts
Posted 21 September 2015 - 10:30 AM
Im in creative and i've tried with a few turtles
CRTL+t works after holding it for a few seconds :)/> Thanks
7083 posts
Location
Tasmania (AU)
Posted 21 September 2015 - 10:41 AM
Being in creative mode has nothing to do with whether or not your turtles have fuel. Try sticking eg a stack of coal into a turtle's inventory, and type "refuel all" into its command line.
The loop you posted will continue to try to go forward until a block is in front of the turtle. If the turtle can't move (eg because it's out of fuel) then it'll indeed sit there doing nothing until you manually terminate it somehow.
21 posts
Posted 21 September 2015 - 10:44 AM
It's working now
it might have been fuel, I didnt know turtles needed fuel in creative
21 posts
Posted 21 September 2015 - 10:55 AM
fuel was the problem, i tested the while loop with and without fuel.
How do I make it so the turtles don't require fuel?
7083 posts
Location
Tasmania (AU)
Posted 21 September 2015 - 12:04 PM
The ComputerCraft config file (located in the config folder of your Minecraft install folder) has a toggle for it.
Make sure the game isn't running when you edit it. If you want to change the setting on the server, then you have to change the server's ComputerCraft config file, as your client's copy only affects SP games.
Edited on 21 September 2015 - 10:05 AM
21 posts
Posted 21 September 2015 - 01:06 PM
Thanks :D/>