|
| 16 Aug 2015 01:52 AM |
| Or maybe just set the environment for the whole game to nil unless otherwise specified? |
|
|
| Report Abuse |
|
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
|
| 16 Aug 2015 01:53 AM |
I THINK you can change the global environment, test it out.
|
|
|
| Report Abuse |
|
|
|
| 16 Aug 2015 02:03 AM |
>Tries in command bar >Realizes that it's its own thing
Well, I got an insight on how Roblox did that, but still. I hope a script will do better. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Aug 2015 02:09 AM |
Just do something like this from a modulescript:
return changeENV = function() setfenv(2, STUFFHERE); end;
And then from a script: require(blah)(); -- code |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2015 02:11 AM |
Interesting...
...but what if the scripts don't exactly /want/ to change their environment?
(Btw this didn't work:
setfenv(0,{_G=_G,error=_G.print}) error("NOT AN ERROR") -->NOT AN ERROR
--Other Script
print("LOL") -->LOL ) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Aug 2015 02:18 AM |
Because the other script has it's own environment, if you made it a module and just called the function it would be fine, so like a module script that does:
return function() setfenv(2, {_G=_G,error=_G.print}) end
So from any script you have, just do require(blah)() and you're done. |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2015 03:08 AM |
"...but what if the scripts don't /want/ to change their environments?"
I gotta figure out some way to force the crap outta them. I just gotta! |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 16 Aug 2015 05:37 AM |
| You can try and traverse the environments and hope that they are using globals. Getting functions that use callbacks are subject to much easier traversal. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Aug 2015 03:41 PM |
| Just make all scripts modulescripts and have a 'master script' require them, so you can change their environments from there. |
|
|
| Report Abuse |
|
|