I think the problem you have is that you're thinking too much about seperate arrays and making it so that your code switches between arrays, checks stuff, etc.... You're focussing too much on that. Forget about all that. You only need 1 array to work with, nothing more. And that array should
only be (re)created when the user enables the "change PSM to random line" feature of your script.
What you need to do in the main code is getting a random line out of
1 array. What that array contains is of no concearn anymore as that array was created and filled at the beginning of your script (aka: when the user changed options). As such it could contain quotes, lyrics, the lines from 5 external files, only the lines from 1 external file, or whatever else you (or the user) wants, combinations of stuff, it doesn't matter.
1) script initializes (or user enabled the feature of the script or whatever): create the array.
2) When timer triggers and PSM must change: read random line from the array. No need to check anything, you already have your array...
quote:
Originally posted by stu
quote:
in that case you do not need the which checking, seperate arrays, and all that other stuff at all. Just concat the lyrics array with your quotes array and be done with it. In other words, you're REALLY making it WAY hard on yourself ...
(and hence my initial suggestion to not alter my example routine at all but instead optimizing your code!).
Yes, I could very well do that, and the reason I did not was that if, going by my example again, I used lyrics, and jokes, they would be displayed different, by adding in front of the lyric, and probably not adding anything to the joke. If i just had them all together, the jokes would also have in front of them.. that is why they are seperate...
No it wouldn't.
That's what I mean with "you're thinking to much about seperate arrays"...
If you want to show "
" in front of lyrics, then add "
" to each lyric line when you
create the array, not when you are showing stuff...
So the array would contain:
"quote one"
"quote two"
"
lyric one"
"
lyric two"
"
joke one"
"
joke two"
You don't need seperate arrays....
In that same matter you can instead add 1 character as an identifiers to each line you add to the array to indicate 'special stuff' to be done when you actually show a line (eg: "Q" for a quote, "L" for a lyric, etc). The point is: you're doing stuff inside the "show it" routine which should actually be done before you show it, not during it...