• 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

Tag manipulation challenge

Lord Magus

Well-known member
An adjustment I created has a chooser from 6 abilities called "affinities"
Choosing 1 of those has a variety of effects, including changing the caster level on spells that I have already tagged (using a sSchool user-defined tag) as linked to said affinity.

I can't find a reference or an example to learn how to do the following:

Extract (pull?) a tag (Affinity.?) from the affinity thing that has been chosen, define a corresponding sSchool.? tag (push?) and then insert this sSchool.? tag in a foreach loop that selects the relevant spells to modify the caster level. In particular, I don't have a clue for the last step (inserting the tag).

Any pointers or examples to help me here? This whole tag extraction and manipulation thing has really been what has been holding me back on a number of scripting projects for this campaign... Thanks!
 
It would look something like this (standard disclaimers like untested, typed in browser, etc...):

Code:
~ finished if nothing is chosen yet in the menu
doneif (field[your_field].ischosen = 0)

~ get affinity tag list from chosen item stored in menu field
var candid as string
candid = field[your_field].chosen.tagids[Affinity.?,"|"]

debug "tag(s) matching Affinity.? are: " & candid

~ finished if no Affinity.? tags were found
doneif (empty(candid) <> 0)

~ switch the tag group to sSchool
candid = replace(candid, "Affinity.", "sSchool.", 0)

debug "updated tag(s) are: " & candid

~ iterate through any picks in the hero container which match
foreach pick in hero from BaseSpell where candid
     eachpick.field[value_to_change].value += 2 
nexteach




If spells need to match all tags (if there are multiple Affinity.? tags) and not just any one tag, you should change "|" to "&" in the tagids[] call above.

You can modify the tag expression (the string stored as candid) to exclude other stuff as needed, for example if the ability shouldn't affect spells cast by items:
Code:
candid = "!Helper.ItemSpell & (" & candid & ")"
 
Back
Top