NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
| |
|
|
| 04 Jul 2015 05:20 AM |
They have a 'local' environment. getfenv() is used for the 'global' environment.
Like, when you do:
function Random() x = 1 end
x is global, so it is placed in the global environment, so ALL other things can see it.
But in this:
function Random() x = 1 local y = 2 end
x is STILL global, and y is LOCAL. So it's only available to its scope, which is the Random function.
So basically, getfenv() retrieves all the GLOBALS because it's available for every thing in the script. Whereas LOCALS are limited to their own scope.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 04 Jul 2015 05:21 AM |
| Will getfenv(Random) include its local variables? |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:21 AM |
No, it will only get the global variables.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 04 Jul 2015 05:23 AM |
| What about getfenv() called from inside Random? If not, is there any way to access/change local variables? |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:26 AM |
Well the only way to change a local variable is to make it a global variable.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 04 Jul 2015 05:28 AM |
Okay, but:
function stuff() local a = 5 getfenv() -- will this include a? end |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 04 Jul 2015 05:30 AM |
| To access local variables, you need to use the debug library. Locals are a part of scope, where the environment isn't. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:30 AM |
Nope.
When you remove the local from a, then it would appear.
function stuff() a = 5 getfenv() -- will this include a? for i, v in pairs(getfenv()) do print(i, v) end end
stuff()
This one WILL have a.
function stuff() local a = 5 getfenv() -- will this include a? for i, v in pairs(getfenv()) do print(i, v) end end
stuff()
This one WON'T have a.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 04 Jul 2015 05:32 AM |
| @power well thanks anyway. I understand how to make a variable not local, what I was wondering is specific to a situation. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:33 AM |
| power.... I need to AFAP... when will it be 100% complete? |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:34 AM |
@Ashley
No problem. C:
@Above
It will be out soon, just finishing off some of the other things.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:37 AM |
omg kewl O3O. Cant wait!!!!!!!!!!!
Also, by tw... how old r u? |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:38 AM |
A bit personal, but it's ok.
I'm actually 9, turning 10 in 1 and a half months.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 05:40 AM |
@power
WOAH O3o
You're birthday is so close to mine :3 |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 04 Jul 2015 06:41 AM |
| you're 9??? I thought you were 13 |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 08:12 AM |
Why would you think that?
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 04 Jul 2015 08:28 AM |
| So you joined when you were five. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 08:33 AM |
Well, not entirely.
My cousin introduced me to ROBLOX, at the time. My cousin used my account for like the first 6 months then explained to me everything.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 04 Jul 2015 09:20 AM |
| So no five, but 6? No difference. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 09:22 AM |
It's actually a 1 year difference.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
MiniNob
|
  |
| Joined: 14 May 2013 |
| Total Posts: 822 |
|
|
| 04 Jul 2015 09:24 AM |
| LOL 2cool4school joined when you were born |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 09:29 AM |
:P
It is worth to note, that all I did for the first 2 - 3 years was play games. Last year I started learning to script.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 09:42 AM |
Such a maturity example.
My brother's your age and there's no way on Earth I'd be able to have civilized conversations with him like I do you O_O
@Not
The function environment is basically full of that functions "globals", there's no way to access locals without the debug library, but that is not available in RBX.Lua, sorry.
What did you need this for anyway? |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2015 09:49 AM |
I am amazed that this thread turned from a smart discussion about getfenv() to a gossip about my age.
Really?
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|