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

[1.4.7][SMP] The code returned nil, then worked

Started by The_Awe35, 06 February 2013 - 03:33 AM
The_Awe35 #1
Posted 06 February 2013 - 04:33 AM
Now, I know this sounds like like a code error, but it isn't. I was working on a program to clear out land. I tried to change the code a bit, didn't work. I changed the code back, still didn't work. Checked the whole code over, no mistakes seen. Looked at another program I made that used the same bit of code as this one. Copied it (variables and all) and still didn't work. I was angry, so I shut down Minecraft. I was going to make a topic in "Ask a Pro" but when I went to check out the error code again, it worked. I didn't change anything to the code, and it didn't work before I turned Minecraft off. This happened about a week ago (I didn't think to put it as a bug until, well, now). I am pretty sure this is the code I used:


if i%2==0 then
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
else
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end

I know this is a incredibly terrible bug report, because I don't know why it happened, how to replicate the bug, or if this was even the for sure the code that gave the error, but this is all I have.

Additional Note: I am using the Tekkit Lite modpack, if that matters at all.
Lyqyd #2
Posted 06 February 2013 - 12:38 PM
Clearly, that is not the full code. Moved to Ask a Pro until full code can be provided and verified.
Pharap #3
Posted 06 February 2013 - 06:32 PM
If you haven't been using local, chances are you dumped something into the global environment in another program that started interfering with your current program.

If you don't use local when declaring a variable, the variable stays on the global table and hangs around there for all programs to see. This is both how things like the math and turtle libraries are available to every program, and how mistakes get made with people forgetting they put a variable into the global table.