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

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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?
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

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

Post by Bugala »

Just figured this out myself:

Code: Select all

test = {A=3}

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

test:Func()
p-OS
Posts: 171
Joined: Mon Nov 01, 2010 11:56 pm

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

Post by p-OS »

exactly.
table:method(x) is the same as table.method(self,x).
Post Reply