Page 1 of 1

Is this doable: test:Func = Function() DebugPrint(self.A) EndFunction

Posted: Fri Nov 08, 2024 12:01 pm
by Bugala
What I am trying to do is basically this:

Code: Select all

test = {A=3}

test:Func = Function() DebugPrint(self.A) EndFunction

test:Func()
By other words, I am trying to make a function, using system of

Code: Select all

Test.Func = Function() Debugprint("test") EndFunction
But when doing it this way, is there a way to use the self option?

Like if I would do:

Code: Select all

Function Test:Func()
Debugprint(Self.A)
EndFunction
This would work fine, but can I do this same the previous way?

Re: Is this doable: test:Func = Function() DebugPrint(self.A) EndFunction

Posted: Fri Nov 08, 2024 7:15 pm
by Bugala
Just figured this out myself:

Code: Select all

test = {A=3}

test.Func = Function(self) DebugPrint(self.A) EndFunction

test:Func()

Re: Is this doable: test:Func = Function() DebugPrint(self.A) EndFunction

Posted: Sat Nov 09, 2024 12:25 am
by p-OS
exactly.
table:method(x) is the same as table.method(self,x).