Hey folks. I've been playing with Bale's CC script, and was trying to generalize a way to find out on which adventure the next SR should be coming up. I apologize for the poor coding style (and variable names
)...it's been a long time since I've written anything.
Of course, this only works if I only have 1 counter (the fortune cookie counter, in this case), or if it is the first in the series of counters. Would anyone please help me generalize this into the scenario where multiple counters might exist, if only for robustness?
Thanks!

Code:
int nextSR(string S) {
string counter_string = get_property("relayCounters");
if(!contains_text(counter_string,S)
return -1;
int x = index_of(counter_string,S);
int adv_of_sr = substring(counter_string,0,x).to_int();
return adv_of_sr;
}
Of course, this only works if I only have 1 counter (the fortune cookie counter, in this case), or if it is the first in the series of counters. Would anyone please help me generalize this into the scenario where multiple counters might exist, if only for robustness?

Thanks!