Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   HL - D&D 5th Edition SRD (http://forums.wolflair.com/forumdisplay.php?f=89)
-   -   Programmatic Way to Add Text to Spell Description (http://forums.wolflair.com/showthread.php?t=66800)

Ambush February 17th, 2022 10:20 AM

Programmatic Way to Add Text to Spell Description
 
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!

Fenris447 February 17th, 2022 11:22 AM

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.

Ambush February 17th, 2022 01:35 PM

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.

Fenris447 February 17th, 2022 02:16 PM

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.

Ambush February 17th, 2022 06:36 PM

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


ploturo February 20th, 2022 01:39 AM

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.

Fenris447 February 20th, 2022 08:13 AM

Quote:

Originally Posted by ploturo (Post 298351)
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.

Quote:

Originally Posted by ploturo (Post 298351)

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!

Ambush February 21st, 2022 08:00 AM

Quote:

Originally Posted by ploturo (Post 298351)
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

Fenris447 February 21st, 2022 11:41 AM

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.

Ambush February 21st, 2022 04:43 PM

Quote:

Originally Posted by Fenris447 (Post 298368)
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.

Quote:

Originally Posted by Fenris447 (Post 298368)
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.


All times are GMT -8. The time now is 08:51 PM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.