lua question: matches[n] shorthand syntax?
lua question: matches[n] shorthand syntax?
Is there any chance that there exists a shorthand syntax for matches[n]?
Re: lua question: matches[n] shorthand syntax?
Someone else raised this issue too. Compared to zmud/cmud where it's just %n, this is too bulky.
How about m[n]?
How about m[n]?
Re: lua question: matches[n] shorthand syntax?
That would work for me.
Re: lua question: matches[n] shorthand syntax?
The problem is now adjusting it, two years later. We'd have to keep both matches[2] and m[2]... hm. I wonder if there's a metatable hack you could do to mirror the values.
Re: lua question: matches[n] shorthand syntax?
Yeah, metatables can certainly be used for this. Here's a bit of code I hacked out which should explain the process fairly well:Vadi wrote:The problem is now adjusting it, two years later. We'd have to keep both matches[2] and m[2]... hm. I wonder if there's a metatable hack you could do to mirror the values.
rawset accesses table data -without- calling metatable information, without it you get stack overflows on trying to add to a table via it's own __newindex function.
Re: lua question: matches[n] shorthand syntax?
After reading anouther post on the forum. It occured to me that you could always put the following at the head of your trigger scripts... given that 'matches' is a Lua table.
(I have not tested but being that m and matches are global tables... you may only have to do this once.)
Re: lua question: matches[n] shorthand syntax?
This doesn't work, I believe it's because the matches table is recreated every time an alias/trigger files, and it breaks the reference.Omit wrote:After reading anouther post on the forum. It occured to me that you could always put the following at the head of your trigger scripts... given that 'matches' is a Lua table.(I have not tested but being that m and matches are global tables... you may only have to do this once.)
This works:
Re: lua question: matches[n] shorthand syntax?
Yeah, it does do that. I wonder if it's the most optimal thing to do now, hm.