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

Why does that Programm not work

Started by darkwarecookie, 27 August 2017 - 12:26 PM
darkwarecookie #1
Posted 27 August 2017 - 02:26 PM
Hello i have an problem with my Programm, i wanted the programm to say "finally it done" if the turtle detect a Block in front, but the turtle says always "finally it done"
Edited on 28 August 2017 - 01:22 AM
Bomb Bloke #2
Posted 27 August 2017 - 02:46 PM
"x" is a global variable, and (prior to 1.80) ComputerCraft doesn't clear your globals when your scripts end. This means that once "x" is set to 5 it'll stay that way until the turtle reboots. See this tutorial for more information about locals, globals, and scope.

Adding "local x" as the first line of your script should fix it.