IdealDev
|
  |
| Joined: 25 Mar 2010 |
| Total Posts: 105 |
|
|
| 09 Oct 2014 10:19 AM |
I see this a lot in game dev livestreams. _G.somethinghere First of all, what is it called? Second, what is it used for and how do I use it? Please help :c |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2014 10:22 AM |
Its global function allows script connect each other like if you have 2 scripts and in first script you defined a is =1 and you ask script 2 what is 1 it would say its nil value because you didn't define a in second script but if you global it will work.
http://wiki.roblox.com/index.php?title=Global_function |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 09 Oct 2014 10:22 AM |
_G is the global variable. Roblox decided they'd mess with it and now you actually have to refer to _G.Variable but whatever It's a part of the core Lua, and it's where stuff like math and all the string methods come from
To assign something to _G, use _G.Var = Something To read from _G, use _G.Var
To assign a function to _G, use _G.Func = function(args) code end
I trust you understand Lua, and know I'm not literal with my naming of Var and Func. Also code. |
|
|
| Report Abuse |
|
|
|
| 09 Oct 2014 10:23 AM |
Ooh, I never knew Roblox supported Global functions :o
I'm gonna have some fun with this.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
IdealDev
|
  |
| Joined: 25 Mar 2010 |
| Total Posts: 105 |
|
| |
|