302 posts
Posted 16 October 2012 - 06:32 PM
ComputerCraft Version Information: 1.3 Client / 1.3 Server
Description of Bug:
After running any program, the program's namespace, eg. functions, variables ect is accessible from the Lua interpreter.
Steps to Reproduce Bug:
Run a program, e.g. save 'var=3' as test, run test, enter the lua interpreter, and type var and enter.
I don't know if it this is intended, but it seems out of character for such a clear language as Lua.
818 posts
Posted 16 October 2012 - 06:35 PM
don't post a bug of a depreciated version. atleast test if the bug exists in the recommended version(1.41)
Tekkit I guess?
After looking this through, this is not even a bug. everything that you run gets put on the RAM kinda(don't really know if it's the RAM but it's a close reference) and it's accesible until you restart the computer
463 posts
Location
Germany
Posted 16 October 2012 - 06:38 PM
I think thats normal, because the var3 is global and you can reach it from all programs (like the lua program)
To remedy that, only put a 'local' before the variable declaration
871 posts
Posted 16 October 2012 - 06:39 PM
Globals persist after programs terminate, that's how globals work. If its a problem make the variables and functions local.
Edit: ninja'd!
231 posts
Posted 16 October 2012 - 06:40 PM
This is intended. If you assign a variable without the local keyword, it is assigned in the global scope, and is accessible from anywhere in the lua environment until the computer reboots, or its set to nil. If you want a variable to be deleted after a program exits, use local var=3.
302 posts
Posted 16 October 2012 - 10:31 PM
Thanks, I know how to declare local variables, I just though that each program got a separate namespace. Adding the solved bracket to the topic. EDIT: how do I add it? Or isn't it me who should do it?
871 posts
Posted 17 October 2012 - 02:51 AM
after clicking edit you have to click the "use full editor" button below the post to be able to edit the topic.