• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Is there a string-friendly version of "tagnames"?

TheIronGolem

Well-known member
I have an ability that needs to loop through a series of custom dynamic tag groups I've made, and append each tagname it finds in each group to a string.

Basically, the groups look like this:

Code:
<group id="custgroup1" name="Custom Group 1" dynamic="yes"></group>
<group id="custgroup2" name="Custom Group 2" dynamic="yes"></group>
<group id="custgroup3" name="Custom Group 3" dynamic="yes"></group>
etc...

Then I'm dynamically adding tags to the ability with names, like "custgroup1.foo", "custgroup1.bar", "custgroup2.baz", etc, with names of "Foo", "Bar", and "Baz" respectively.

And I'd like to turn that into a string that looks like "Foo, Bar, Baz"

I figured I could do it like this:

Code:
var myStr as string
var i as number
for i = 1 to 3
  myStr &= tagnamestr["custgroup" & i & ".?"], ", "]
next

But it turns out I was wrong to assume that there's a "tagnamestr" method. And I couldn't find any reference to one in the wiki. Is there a way to get tagnames according to a string (like tagidstr, but returning names instead of ids)? Or (as I suspect) do I need to give up on the loop and just do each group manually?
 
Couldn't you just use a splice for each tag group?

Code:
var myStr as string
myStr = splice(myStr, tagnames[custgroup1.?, " or "], " and ")
myStr = splice(myStr, tagnames[custgroup2.?, " or "], " and ")
 
He is trying to not have to hard-code the tag group why he was trying to use a soft-coded approach.

Basically I don't see anyway around it myself so you need to do what Aaron said or basically hard-code the tag groups into the script.
 
Yeah, I went ahead and did it the hardcoded way shortly after posting the thread. I had hoped that if I took the trouble to do it the hard way, then someone would immediately show me a better way that made all the work I had done unnecessary. So much for my attempt to harness irony...

Still, it's nice to know about that splice function. That isn't in the wiki, so at least I did learn something new.
 
Back
Top