View Single Post
Old 11-10-2019, 10:18 PM   #604
Human being with feelings
woodslanding's Avatar
Join Date: Mar 2007
Location: Denver, CO
Posts: 428

Originally Posted by cfillion View Post
They're called vararg functions: The vararg expression ... (three dots) stores all extra parameters that were given to the function (it's not a table, more like functions with multiple return values).
Thanks! A lot of good information there about how arguments work.

I'm going to have to get my head around passing functions around. It's all new to me and makes my head spin a bit....

As an example, in 'working with images' I find:

if self:containsPoint(state.mouse.x, state.mouse.y) then

self.params here refers to func's self, is that right? Am I right in thinking that func as an argument to the control should be the function we want it to execute when the button is pressed?

I'm trying to imagine what syntax I would use to have the func parameter call an action that required the value of self.state as an argument... I've figured other ways to do that without func, (basically overriding the control's mouse methods with direct calls) but it seems like I'm missing the point. There is an easier way, correct?

Okay, searched in Knob.lua, and it looks like the func argument is not being used in this way there, so maybe I was mistaken. Is what I'm talking about above possible? or desirable?
eric moon
Very Stable Genius

Last edited by woodslanding; 11-10-2019 at 10:55 PM.
woodslanding is offline   Reply With Quote