MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 27 May 2015 10:10 AM |
| Here is the code for the script, because I don't think the forums support indentation: http://prntscr.com/7a0bd1 |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:13 AM |
1. Forums do support indentation now. 2. 'self' for tables is inclusive when setting metatables:
local tab = {some_value, "hi", 123} setmetatable(tab, {__call = function(self, ...) local args = {...} -- etc etc end})
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:13 AM |
local functionTable = {}
functionTable.Function = function(self, text) print(self, text) end)
functionTable:Function("Test") |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:13 AM |
I misread. Refer to ^
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:14 AM |
@epic, *end
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 27 May 2015 10:15 AM |
| @epicbreaker So you're saying that "self" must be a parameter of the function? Will that give the core table or the functions table though? I want it to give the "father" table, not the nested one. |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 May 2015 10:15 AM |
^
Really... Was that needed lol. :P |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:16 AM |
| It should give the table the function is currently in. |
|
|
| Report Abuse |
|
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 27 May 2015 10:17 AM |
| Okay, so then how do I get the "father" table from the nested table? |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:17 AM |
Just use 'parent'
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:18 AM |
As the terminology, I meant. He keeps saying 'father.'
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:21 AM |
| I'm not sure it's possible. |
|
|
| Report Abuse |
|
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 27 May 2015 10:22 AM |
Here's a visualization of what I want http://prntscr.com/7a0gtj |
|
|
| Report Abuse |
|
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 27 May 2015 10:23 AM |
| MY MISTAKE, THAT'S OLD LINK, give me a minute to get new one |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:24 AM |
To my knowledge, you can't.
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:24 AM |
You can't.
"return Core" will be the only way. |
|
|
| Report Abuse |
|
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
| |
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 27 May 2015 10:28 AM |
Nevermind. I can make a parameter called core, and then outside of the function, call the script and set the argument for core to _G.core.
SOLVED SOLVED SOLVED SOLVED SOLVED SOLVED
|
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:30 AM |
You could attempt using table.insert
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:21 AM |
These idiots are idiots, you shouldn't make self a parameter of the function. You have to create a "method" for this to work:
local tab = {}
function tab:Foo() print(self==tab) end
tab:Foo() --> true |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 27 May 2015 11:30 AM |
Tables don't know where they're contained because they're passed by reference. If they need to know where they're contained it needs to be set in a key Methods can be declared as function tableName:MethodName(...) -- code; self is implicit end or, tableName.MethodName = function(self,...) -- code end Both of which would be called as tableName:MethodName(...) and self would be passed by the :Syntax Not really good for anything but classes or __index functions |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 May 2015 11:46 AM |
| I already rescued, noob, gtfo. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 27 May 2015 11:48 AM |
| Did somebody ruin your cornflakes this morning? Also you said they had to be constructed as function t:M(...) which is totally wrong - They don't *have* to be written like that at all. |
|
|
| Report Abuse |
|
|