• 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

Programmatic Way to Add Text to Spell Description

Ambush

Well-known member
I know we can't add to the xml export used for printing, but I'm trying to figure out a way to denote ritual spells in the export. In the very short term, I've created copies of spells, replaced the original, and added *ritual* to the end of the description. In my xsl transform, I find that value, set a variable, and strip it out of the text. I do not enjoy this, and I'm reluctant to want to do it for every ritual spell. So here's the question:

Given that there is a tag on the spell that denotes if it's a ritual, is there an eval script or something else that I can use at a high level to automatically add to the end of the description text?

To be clear, I am looking for a solution that is NOT to modify each individual manually, but something that would also work for any new spells that get added by default (i.e. due to the ritual tag).

Thanks!
 
Off the top of my head, something like:

Code:
~find every spell with the ritual tag
foreach pick in hero from BaseSpell where "Helper.RitualSpel"

~set the name to be the name & ritual
    eachpick.field[livename].text = eachpick.field[name].text & " (Ritual)"
    nexteach

You may need to experiment with the timing, and which fields you're modifying and using (name, thingname, shortname, livename, etc.).

Throw this eval script onto an adjustment, add that adjustment to the hero.
 
Last edited:
There were some minor updates to the script, but overall, you got me there. I can see the updated description in the app. Thank you Fenris.

The only catch? The XML export does not use that description, or I'm updating the wrong thing.
 
Oh I was going for updating the name of the spell. What are you using for description? My first try for that would be the CustDesc field. But I have no idea if that goes into the printing.
 
You got me close enough that I figured it out anyway. :) Even though it was no joy on the final result.

In the end, the script was:
Code:
doneif (tagis[Helper.Disable] <> 0)

~find every spell with the ritual tag
foreach pick in hero from BaseSpell where "Helper.RitualSpel"
    ~set the name to be the name & ritual
    eachpick.field[CustDesc].text = eachpick.field[descript].text & " *ritual*"
nexteach
 
There may be some differences, since I am messing around in pathfinder, but it seems like the XML custom output just uses the original descript field.

It does seem to use the livename field for the name, and adding a spell descriptor tag (like the good or evil descriptors) using sDescript.Good is added to the xml output.

If 5E doesn't have spell descriptors, maybe add a new school tag for Rituals, if that gets added to output.


You can limit the changes to output only by checking for state.isoutput like this:

Code:
if (state.isoutput <> 0)
   ~ make whatever changes
endif

That way if you want to make a change to the spell's livename (for example) for the xml output that you don't want to show up within the regular app, you can. The changes would show up on all types of 'output', like the printed character sheet(s) and stat blocks too.
 
If 5E doesn't have spell descriptors, maybe add a new school tag for Rituals, if that gets added to output.

It doesn't, but that's a good alternate approach! Although you'll forever see that ritual "school" in your own data files, which would bother me. But YMMV.

You can limit the changes to output only by checking for state.isoutput like this:

Now that is awesome. Never knew that. I've yet to have a need to alter output only, but what a great tool to have in my back pocket. And perfect for OP's needs!
 
You can limit the changes to output only by checking for state.isoutput like this:

Thanks for that addition, Ploturo, that's pretty cool.

Unfortunately, I get an error when I try to set the descript field:
Only derived fields can generally be modified via scripts

Which upon research *could* be able to be gotten around with a "trustme", but that still throws a compilation error, so maybe not. I've tried the trustme both in and out of the loop to set each spell's descriptor.

Which leads all the way down to this script:
Code:
doneif (field[pIsOn].value = 0)
doneif (state.isoutput <> 1)

~find every spell with the ritual tag
    foreach pick in hero from BaseSpell where "Helper.RitualSpel"
        ~set the name to be the name & ritual
        eachpick.field[sNameMod].text = "*r*"
    nexteach

And this does what I need it to do. It's not the prettiest solution, but it's functional and only shows up on the output xml. I don't love playing with the name field, because it's technically an identifier here, and I also don't love using sNameMod, because I don't know if this will blow up something else somewhere along the way, but it works. And that's good enough for now.

+1 for Fenris
+1 for Ploturo
 
sNameMod is used in the community pack a lot, so it's not the best idea. Though you could do

eachpick.field[sNameMod].text &= "*r*"

That adds to any existing sNameMod, but might be overridden if sNameMod is changed later in the timing.

As for the derived fields, descript isn't a modifiable one. But you had the right answer earlier; set CustDesc to descript + whatever you wanna add on.
 
sNameMod is used in the community pack a lot, so it's not the best idea. Though you could do
eachpick.field[sNameMod].text &= "*r*"

I'll update my local implementation with that.

As for the derived fields, descript isn't a modifiable one. But you had the right answer earlier; set CustDesc to descript + whatever you wanna add on.
Unfortunately, the export doesn't use the CustDesc, so it doesn't help me any.
 
I hope you haven't gotten too frustrated with trying to implement this, but there is a way for you to edit the spells' original thing descript field dynamically.

I realized today that the fact that amendthing[ ] only works from within a thing context isn't actually a roadblock, because there is a trivial way to dynamically get the thing context(s) you need.

Combining amendthing[ ] with state.isoutput you should be able to change the descriptions to add the indicator for rituals to the descript field just during output.

The code below uses pathfinder specifics and a different tag, but hopefully it should translate just fine to the equivalent in 5E.
Code:
~ don't continue if adjustment isn't activated
doneif (field[pIsOn].value = 0)

if (state.isoutput <> 0) then

    foreach thing in BaseSpell where "sDescript.Good"

        perform eachthing.amendthing[description,eachthing.field[descript].text & "*Good*"]
        
    nexteach
    
endif

It temporarily adds the extra text to the descriptions of all spells with that tag whether or not they are being used, but it won't catch any spells where the tag was added to the pick later by a script.

If that second part is a problem, you might be able to use a similar method to iterate over the picks like before and change them one at a time using a second internal foreach thing with "thingid.whatever" to make it specific to that pick's thing and then makes the change as above, although timing when the script runs might end up being more complicated.
 
Back
Top