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

[Solved] Os.run with _G table

Started by Ajt86, 13 January 2016 - 07:56 PM
Ajt86 #1
Posted 13 January 2016 - 08:56 PM
When calling os.run with the global table, I get a "loop in gettable" error.

How would I use it with the global table?
Edited on 14 January 2016 - 08:03 PM
Micheal Pearce #2
Posted 13 January 2016 - 09:01 PM
are you trying to pass _G through os.run so the program can use it?
Bomb Bloke #3
Posted 14 January 2016 - 12:29 AM
… if so, don't. They have access to it anyway. Either make a new environment table, or, if you want to run the script using the same environment as the shell you're using, use shell.run() instead.
Ajt86 #4
Posted 14 January 2016 - 04:15 PM
They have access to it anyway.

I've tried passing it an empty table, but that doesn't work, they don't have access to global environment variables previously set in the same program (and that's also a relief for sandboxing).
Edited on 14 January 2016 - 03:16 PM
MKlegoman357 #5
Posted 14 January 2016 - 06:11 PM
Why are you using os.run instead if shell.run? If you can, you should be using shell.run, as it runs the programs in a proper environment. The global variables of programs are stored not in the _G table but rather in the shell's program environment, so to get that the best way would be to use shell.run.
Lupus590 #6
Posted 14 January 2016 - 06:23 PM
http://www.computercraft.info/forums2/index.php?/topic/25561-what-is-the-difference-between-shellrun-and-osrun/

this AAP may help
Ajt86 #7
Posted 14 January 2016 - 09:03 PM

Thank you Lupus but I already know what each one does. I've solved the problem by assigning all the global variables I want to pass down to a key in a table, which I then pass in to os.run/