LUA: Passing a local table to a function (for tempTriggers)
Posted: Tue Nov 09, 2010 12:28 pm
I'm wondering if there is any way to pass a local table value into a trigger/timer, and have it come out on the other side able to use it. I want to be able to pass in the local "self" table, so I can use it within the temp trigger and or timer.
So, someway to pass a local table value into the tempRegexTrigger() like so:
And yes, I'm aware I could just use a global variable. But I'm trying to avoid that.
EDIT: I tried the following with no success:
Doens't work because you can't concatenate a table value
Thus, An actual example of what I'm trying to accomplish (heavily simplified) is as follows:
So, someway to pass a local table value into the tempRegexTrigger() like so:
So I'd want triggerStuff = {"stuff"}, whereas it would simply throw an error as written above.
And yes, I'm aware I could just use a global variable. But I'm trying to avoid that.
EDIT: I tried the following with no success:
Doens't work because you can't concatenate a table value
I'm asking because I'm writing an object to handle success/fail triggers and timeout commands, and I want to refer back to the calling object/function from within a temp trigger and or timer. Of course, when the trigger is fired, the 'self' table doesn't work, I assume because the trigger code is not being executed from within the original function where 'self' is defined. So when you do something like tempRegexTrigger("hello world",[[self:Start(lua)]]) it doesn't know what 'self' is.
Thus, An actual example of what I'm trying to accomplish (heavily simplified) is as follows:
I had this working without making it into an object, but the inheritable object is nice as you can keep track of the states easily, and have multiple success/fail triggers. I also added a "max retries". It's just simpler within an object than keeping track of all the values in a big list. I suppose I could cheat the inheritance and just call waterfall:Complete() instead of self:Complete(), but that kind of defeats the purpose.