|
| 01 Jan 2011 08:05 AM |
| What does that do? and what does _index do ? |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2011 08:16 AM |
_G is a global table. You can add variables to it and those can be accessed in other scripts (I dont think client-side scripts can get server-side globla varaibles)
EG:
Script1:
_G.LOL = "LOL"
Script2;
print(_G.LOL)
OUTPUT:
>LOL |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2011 08:16 AM |
| UHG ANOTHER LATE PST BY ME D: |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jan 2011 08:18 AM |
| So its a substitute for source? |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2011 08:19 AM |
| Script.Source? Not really, I dont think. You can hold functions, numbers, strings... ANything that can be in a normal table. |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2011 08:20 AM |
well i mean like
_G.print = game.Workspace.Part1:remove
script;
... O wiat nvm.. But you could insert that unto a table i guess. |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2011 08:22 AM |
Well, you COULD do _G.print = function(var) workspace.Part1:Remove() end _G.print("LOL" |
|
|
| Report Abuse |
|
|
| |
|
bloob827
|
  |
| Joined: 01 Aug 2010 |
| Total Posts: 6867 |
|
|
| 01 Jan 2011 09:17 AM |
__index is a metamethod, _index is nil. >_>
__index fires when something is looked up in a table.
For example:
table = {"hello", "hi"}
metatable = {__index = function() return print("no access allowed") end })
setmetatable(table, metatable)
print(table[2]) > no access allowed
Or:
table = {"hi", "hello"} setmetatable(table, {__index = function() print("TheRandomText") end })
print(table[1]) > prints 'hi' and prints 'TheRandomText' |
|
|
| Report Abuse |
|
|