|
| 19 Jan 2014 07:45 PM |
tableA = { testA = 5;
tableB = { testB = testA + 1; };
}
print(tableA.tableB.testB)
20:42:30.876 - Workspace.Hit List:5: attempt to perform arithmetic on global 'testA' (a nil value) 20:42:30.877 - Script 'Workspace.Hit List', Line 5 20:42:30.877 - stack end
How would I reference testA from inside tableB? |
|
|
| Report Abuse |
|
|
Azureous
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25287 |
|
|
| 19 Jan 2014 07:47 PM |
tableB = { testB = tableA[1] + 1; };
print(tableB[1]) |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:50 PM |
Tables don't have 'scopes'. Being inside a table doesn't mean you can access all its members as you would with variables, also, the values are not assigned in order like variables either:
tableA = { testA = 5; };
tableA.tableB = { testB = tableA.testA + 1; }; |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:57 PM |
So it's impossible to get members of a parent table from within a child table?
I can't even do this:
tableA = { testA = 3;
tableB = {--INSIDE TABLE A testB = tableA.testA + 1 };
}
|
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:59 PM |
Nope, like I said, they don't work like variables... Either do it the slow way or use normal variables within do blocks:
do local TestA = 3; do TestB = TestA + 1; end end print(TestA, TestB) --> nil, 4 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 19 Jan 2014 09:10 PM |
tableA = { testA = 5;
tableB = { testB = tableA.testA + 1; };
} |
|
|
| Report Abuse |
|
|