generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Can I setfenv() other scripts?

Previous Thread :: Next Thread 
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
16 Aug 2015 01:52 AM
Or maybe just set the environment for the whole game to nil unless otherwise specified?
Report Abuse
iiEssence is not online. 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
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
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 is not online. 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
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
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 is not online. 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
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image