Ah, right. That was off the top of my head - anyway, the questions still stands, and I'll try to clarify what I meant a bit.
Say I get this from the MUD:
You see some cheese.
H:100 M:100 mv:68>
It is yellow with spots on.
H:100 M:100 mv:68>
It's cheese man, what do you want? Seriously.
H:100 M:100 mv:68>
And I want it to look like:
TARGET ACQUIRED: cheese
H:100 M:100 mv:68>
TARGET STATUS CHANGED TO: yellow with spots on.
H:100 M:100 mv:68>
TARGET CONFIRMED: cheese
H:100 M:100 mv:68>
Assume I have a hundred more similar substitutions on all sorts of lines, many of them happening several times a minute. Would it then be better to have:
A) a hundred separate triggers, each with one
selectString(line,1) and one
replace("Line to substitute in here"). One trigger for each line I want to sub, each trigger has only that particular line as the pattern.
or B) A single trigger with just one pattern
(.+) (or substring equivalent - I still haven't looked at those even though they're supposed to be faster) and a hundred different
selectString("You see some cheese.",1) and
replace("TARGEtcetera")
The second option would have to match and run on every line coming from the MUD, but the first option would mean a LOT more triggers to parse per line the mud sends. So my question is basically, would the second option, with a single pattern but lots of code, be "faster"?
(I haven't had any speed problems yet, but at this rate I'll have about nine point five billion triggers by this time next year
)
On a sort of sidenote, if I ended up using the second method, should it look like this:
Code: Select all
selectString("You see some cheese.",1)
replace("TARGET ACQUIRED: Cheese")
selectString("It is yellow etc",1)
replace("TARGET STATUS CHANGEtc")
selectString("It is cheese man.",1)
replace("TARGET CONFIRMED")
or like this:
Code: Select all
local ternary=selectString("You see some cheese.",1)>-1 and replace("TARGET ACQUIRED: Cheese")
local ternary=selectString("It is yellow etc.",1)>-1 and replace("TARGET STATUS CHANGEtc")
local ternary=selectString("It is cheese man.",1)>-1 and replace("TARGET CONFIRMED")
That is, would a lot of replace() calls while nothing is actually selected be bad, or would it be worse to have a hundred if statements? (or makeshift ternary conditionals as above - not sure if that works and can't remember where I got the idea from)