K. Grimy finally got back up so I posted my fighit snippet too.
When I ran a speed test I found that getText is dependant on the length of the text being processed. I don't know if that's true of getWord or cuttext. But after 100000 iterations I was able to average under .05ms w/ my old snippet.
This is the CURRENTANSILINE for a subby I'm in. #27 is replaced by _ for clarity.
_[K_[1A_[1;33mDeployed Fighters _[0;32mReport Sector _[1;33m4465_[0;32m: _[1;36m_[33mAscian Wanderer_[36m Jedi Boexif's _[0m_[31mAscian Troller_[32m entered sector.
As you can see, prome's "_[1;36_[33m" snippet would work if #27 was there (dang forum), but only if the alien race color is always [33m. I'd also be a little concerned about false positives (dunno, not sure if it would ever happen) by using the full ansi line as a test.
What's interesting is I tested this in several variations...
1. With the code preset to a variable like:
setVar $test #27 & "[1;36m" & #27 & "[33m"
2. With the code being generated each time:
getWordPos CURRENTANSILINE $pos #27 & "[1;36m" & #27 & "[33m"
And got 2 very different results
The first was .0313ms for a 100k iteration avg. The 2nd was .0408ms. So building the line each time is adding some .009ms to the process.
When I added a getWord in there like this:
Code:
getWord CURRENTANSILINE $alien_check 6
getWordPos $alien_check $pos #27 & "[1;36m" & #27 & "["
if ($pos > 0)
# Blah
end
I went up another .01ms. So by doing the combination...
Code:
getWord CURRENTANSILINE $alien_check 6
getWordPos $alien_check $pos $alien_ansi_code
if ($pos > 0)
end
And setting $alien_ansi_code to:
setVar $alien_ansi_code #27 & "[1;36m" & #27 & "["
Earlier, outside of the 100k test loop, I got:
Milliseconds per execution: 0.0416
Which is pretty dang fast, only marginally slower than Prome's and only because of the getWord to smooth out my one concern.
A cuttext only added about .001ms. A gettext only about .003ms there.
This seems to suggest that getText is actually faster than getWord. So I'm going to test it to confirm.
Code:
getText CURRENTANSILINE $alien_check ": " "'s"
getWordPos $alien_check $pos $alien_ansi_code
if ($pos > 0)
# echo "*Alien*"
end
Where $alien_ansi_code is set.
I get an amazing...
Milliseconds per execution: 0.0367
Which is faster than my getWord variation and dang close to Prome's first variation.
getText seems to only take about .005ms !!
Food for thought.
Conclusion:
These are TINY amounts of time. So fast you won't recognize it, even in a photon script. But if you're looking to improve your time on 2.04 it seems that you should:
1. Use getText instead of getWord
2. Use cutText instead of getText
3. Pre-set as many variables outside of the input testing