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

Replace parts of _G not working.

Started by PixelFox, 01 August 2015 - 06:53 PM
PixelFox #1
Posted 01 August 2015 - 08:53 PM
So, I'm working on a program that turn shell.run() into something else, and _G.lol into shell.run()

The code I have is:

_G.lol = _G.shell.run
_G.shell.run = function()
   print("Testing Testing 1 2 3")
end
Edited on 01 August 2015 - 06:54 PM
Lignum #2
Posted 01 August 2015 - 09:10 PM
So… what's the problem? This should work fine.
PixelFox #3
Posted 01 August 2015 - 09:14 PM
It doesn't work for some reason.
PixelFox #4
Posted 01 August 2015 - 09:20 PM
Wait, Fixed it.
flaghacker #5
Posted 01 August 2015 - 09:28 PM
Also, you can remove every single _G in that program.
Lyqyd #6
Posted 01 August 2015 - 09:46 PM
A big part of the reason this wouldn't have worked is because the shell "API" isn't a real API, and therefore is not found in _G. It's an interface exposed to programs running under and individual shell instance.