• 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

A few more script questions

Bob G

Well-known member
Hi everyone,

I've got a few more questions about scripts that are confounding me. Any help would be very appreciated.

1. Trying to put a class ability that grants fast healing when current hit points are below 50% of total hit points. I'm having trouble locating the child that current hit points are stored. Can anyone help direct me?

2. Another problem is a custom expression I am trying to write that does a foreach on memorized spells. I found a tag group name 'Memorized', so I used the following script:
Code:
foreach pick in hero from BaseSpell where "Memorized.?"
     field[usrCandid1].text = splice(field[usrCandid1].text, eachpick.tagids[thingid.?], " | ")
     nexteach
But the results produced all spells in the hero's spellbook, not just the ones they had memorized. What's the correct tag to use in the custom expression?

3. Lastly (same ability as #2), once the user selects a memorized spell, I want to change the tag or field to reflect that it has been cast. I found the field 'sCastCount', but that produced an error message, so I tried decreasing the field 'sCastLeft', which didn't error, but did not produce the desired result. Guidance on this would be great.

Thanks as always, and happy holidays to all of you.
 
Update to question 1: I found the child by using the 'Show Task List (Active Hero)' floating info window in the Develop menu! Total and current hit points are stored in the child "Totals".

I hope this helps anyone with similar problems.
 
The spells cast is tracked in the in play or spells tab.

Right, I found those, but none of the fields that I tried accomplish the goal. I tried 'sCastCount', but that produced an error message, so I tried decreasing the field 'sCastLeft', which didn't error, but did not produce the desired result. Not sure where to go from here.:confused:
 
What are you trying to do with the loop/script?

I am trying to write that does a foreach on memorized spells. I found a tag group name 'Memorized', so I used the following script:

Code:
foreach pick in hero from BaseSpell where "Memorized.?"
     field[usrCandid1].text = splice(field[usrCandid1].text, eachpick.tagids[thingid.?], " | ")
     nexteach
But the results produced all spells in the hero's spellbook, not just the ones they had memorized. What's the correct tag to use in the custom expression?

The goal is to create a usr field where the candidates are memorized spells.
 
Is this limited to just spellbook casters, or should it be catching, for example, spells memorized by a cleric? Should it not be iterating through spells known, like a sorcerer gets?
 
Is this limited to just spellbook casters, or should it be catching, for example, spells memorized by a cleric? Should it not be iterating through spells known, like a sorcerer gets?

Just spellbook casters, this is a class ability for a class that memorizes arcane spells.
 
SpellType.cHelpXXX (replace XXX with whatever is appropriate for your class) and CasterType.MemBook
 
SpellType.cHelpXXX (replace XXX with whatever is appropriate for your class) and CasterType.MemBook

Thanks Aaron. I got an invalid tag expression when I used this script:
Code:
foreach pick in hero from BaseSpell where "SpellType.cHelpArn" &  "CasterType.MemBook"
I get the feeling it's because the tag "SpellType.cHelpArn" isn't located in the BaseSpell component.
 
No, it's that you close and then re-open the quotes inbetween the SpellType and CasterType tags. The errror said "invalid tag expression", so you're looking for typos and mistakes in the tag expression, which is the part after "where".
 
When you close the qoutation, the ampersand is only joining the first part of the tag expression to the second part, rather than being interpreted within the expression.

"SpellType.cHelpArn" & "CasterType.MemBook"

is interpretted as

"SpellType.cHelpArnCasterType.MemBook"

Which is gobbledygook to the program. You want the "and" inside the expression, like so:

"SpellType.cHelpArn & CasterType.MemBook"
 
When you close the qoutation, the ampersand is only joining the first part of the tag expression to the second part, rather than being interpreted within the expression.

"SpellType.cHelpArn" & "CasterType.MemBook"

is interpretted as

"SpellType.cHelpArnCasterType.MemBook"

Which is gobbledygook to the program. You want the "and" inside the expression, like so:

"SpellType.cHelpArn & CasterType.MemBook"

Well that makes sense now. Thanks to both of you.

I tried keeping everything inside of the quotations, and it worked...almost...perfectly. It now is only selecting memorized spells, but is listing them twice in the usr field. Do you know why?
 
Hi everyone,

Still trying to get this to work as intended. The foreach statement below is pulling all spells from the hero's spellbook, not just the ones that are memorized. Plus, it is pulling the same results twice on certain spells.
Does anyone know what is going on here?

2. Another problem is a custom expression I am trying to write that does a foreach on memorized spells. I found a tag group name 'Memorized', so I used the following script:
Code:
foreach pick in hero from BaseSpell where "SpellType.cHelpArn &  CasterType.MemBook"
     field[usrCandid1].text = splice(field[usrCandid1].text, eachpick.tagids[sLevel.?], " | ")
     nexteach
But the results produced all spells in the hero's spellbook, not just the ones they had memorized. What's the correct tag to use in the custom expression?
 
If this is still the same issue we talked about in e-mail, I still don't think a selector is the correct way to choose to "burn" a spell as though it were cast. But, if you are dead set on doing it that way I will take a second look.
 
If this is still the same issue we talked about in e-mail, I still don't think a selector is the correct way to choose to "burn" a spell as though it were cast. But, if you are dead set on doing it that way I will take a second look.

Hi Aaron, this is a related issue. I decided to use your recommendation and just allow the user to manually change the status of the spell from 'uncast' to 'cast' on the Spells tab, but my concern is now in the user selection. What I would like to accomplish is that when the user selects a spell to "burn", that spell becomes an invalid choice for future selections, until a day's rest resets the hero's spells.

Does this still present major problems?
 
I don't see how you would represent that, even if you got your selector choosing among the correct spells, unless you had one selector for every possible spell, because HL evaluates the character every time you change something.

For example, say you have your single selector, and you want to mark your choice by assigning a tag when you select a spell, and you've set it up so that your candidate expression for the chooser will not allow your to choose something with this new tag you created.

You add your ability, and you have 3 spells memorized right now, Spell A, B, and C. The tag you assign is Custom.NoPick2x.

On the character, you go to the ability in question and click on the selector, no selection has been made, no tag is assigned, you can choose any of the 3 spells. You make the selection, choosing Spell B, so HL runs an evaluation and your ability assigns Custom.NoPick2x to Spell B. Now you click on the selector again, no change has been made to the character so no evaluation is run yet and you see Spells A and C for selection but not Spell B (since it was assigned that tag last evaluation). As soon as you select either A or C, another evaluation runs and your eval script assigns Custom.NoPick2x to the new choice, and Spell B no longer has that tag. With a single selector applying a tag, there is no way to make your choice "sticky".

There are some things which retain information across evaluations, like user choices (what abilities have been added, what selections the user has currently selected for their abilities), and certain types of fields. Unfortunately, you can't define new fields on a pick, and even if there is a user field not currently being used (say one which relates to, for example, a variant spellcasting system from Pathfinder Unchained), its probably not a good idea to be co-opting it for whatever ability you are making here.

So the only way I can see that you have access to, would be to make this selector be on an ability which could be added as many times as the user needed, for example, through a configurable. The problem is, this is both wasteful and highly annoying to track, if you are expecting the user to add a new ability and select a new spell every time they use this ability. Then delete all the abilities when they rest just to do it all over again the next game day.

It just doesn't strike me as worth the effort for you to code, or your user to use. If you absolutely must have some record of which spells have been burned today, have them note it down on the Personal tab, or add a user text field to the ability and have the user manually type each spell marked off and erase the text at the end of each day. At least that is only one step per use, and a single step at the end of the day (rather than n*2 + n steps for add ability, make selection, delete ability).
 
I don't see how you would represent that, even if you got your selector choosing among the correct spells, unless you had one selector for every possible spell, because HL evaluates the character every time you change something.

For example, say you have your single selector, and you want to mark your choice by assigning a tag when you select a spell, and you've set it up so that your candidate expression for the chooser will not allow your to choose something with this new tag you created.

You add your ability, and you have 3 spells memorized right now, Spell A, B, and C. The tag you assign is Custom.NoPick2x.

On the character, you go to the ability in question and click on the selector, no selection has been made, no tag is assigned, you can choose any of the 3 spells. You make the selection, choosing Spell B, so HL runs an evaluation and your ability assigns Custom.NoPick2x to Spell B. Now you click on the selector again, no change has been made to the character so no evaluation is run yet and you see Spells A and C for selection but not Spell B (since it was assigned that tag last evaluation). As soon as you select either A or C, another evaluation runs and your eval script assigns Custom.NoPick2x to the new choice, and Spell B no longer has that tag. With a single selector applying a tag, there is no way to make your choice "sticky".

There are some things which retain information across evaluations, like user choices (what abilities have been added, what selections the user has currently selected for their abilities), and certain types of fields. Unfortunately, you can't define new fields on a pick, and even if there is a user field not currently being used (say one which relates to, for example, a variant spellcasting system from Pathfinder Unchained), its probably not a good idea to be co-opting it for whatever ability you are making here.

So the only way I can see that you have access to, would be to make this selector be on an ability which could be added as many times as the user needed, for example, through a configurable. The problem is, this is both wasteful and highly annoying to track, if you are expecting the user to add a new ability and select a new spell every time they use this ability. Then delete all the abilities when they rest just to do it all over again the next game day.

It just doesn't strike me as worth the effort for you to code, or your user to use. If you absolutely must have some record of which spells have been burned today, have them note it down on the Personal tab, or add a user text field to the ability and have the user manually type each spell marked off and erase the text at the end of each day. At least that is only one step per use, and a single step at the end of the day (rather than n*2 + n steps for add ability, make selection, delete ability).

Okay, that makes sense. I guess what I can do is create a usr field that allows user to select a spell level. This selection will be used to power the various abilities the class has. The user can then manually select which spell will be burned to fuel the ability. Let me give that a try and see how it turns out.

Thanks as always for your valuable input!
 
Back
Top