• 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

How to allow only one background from a background table?

Zedwimer

Member
This is probably easy to do, but I'm rather new to the editor and I'm still trying to figure out scripting, so hopefully someone here can point the way for me.

I've set up a series of new backgrounds called Themes, all of which are associated to a Theme background table (I even set up a "Themes" header with the "Show Only?" check box). Each of these background themes confers a specific theme feat (for free) upon the player. (I'm sure this is all sounding familiar to some people.) So far, so good; I can pick theme backgrounds in the Other Backgrounds section and their associated feats are properly added to the character.

However, players are only allowed to choose ONE theme for a character... and I haven't figured out how to restrict this yet. Right now, a player can choose multiple themes for their character. I can screen for this the old fashioned way, but I'd like Hero Lab to do it for me if possible. Ideally, once one theme has been applied, the others should be grayed out or not even visible any longer.
 
Create a mechanic with an eval rule that uses a foreach to count the number of Theme Background picks (mark them with a tag, if you are not already) and throws an error if the count is 2 or more. Por ejemplo:

Code:
var count as number
foreach pick in hero from CharBack where "WHATEVERTAGYOURTHEMESHAVE"
  count += 1
  nexteach

validif (count < 2)

panelvalid[history] = 0
 
Create a mechanic with an eval rule that uses a foreach to count the number of Theme Background picks (mark them with a tag, if you are not already) and throws an error if the count is 2 or more. Por ejemplo:

Code:
var count as number
foreach pick in hero from CharBack where "WHATEVERTAGYOURTHEMESHAVE"
  count += 1
  nexteach

validif (count < 2)

panelvalid[history] = 0

Thanks! Is there a specific (or recommended) phase & priority I should assign to this?

I'm also getting an undefined variable error with "panelvalid" on the last line. I'm guessing something's missing here. Should that be "container.panelvalid[history]"?
 
Thanks! Is there a specific (or recommended) phase & priority I should assign to this?

I'm also getting an undefined variable error with "panelvalid" on the last line. I'm guessing something's missing here. Should that be "container.panelvalid[history]"?

I just gave "container.panelvalid[history]" a try and it got rid of the error. I also set the phase to "Validation" and gave it all a whirl... and it seems to be working; it's now giving a validation error (and the History tab goes red) if I pick more than one Theme for a character. Thanks again, Aaron!

A follow-up question: how hard would it be (if its even possible) to actively prevent the player from choosing a second theme? Such as to make the other themes "grey-out" or even disappear from the list of clickable backgrounds once a theme is added to the character.
 
Well, you could have each of your themes apply a Custom.WHATEVER tag to the hero via an eval script, and then give each one a pre-req that says "If there is a Custom.WHATEVER tag on the hero, then we are invalid, unless we are already a pick (which means we are already added to the hero and we are the one responsible for applying Custom.WHATEVER)."

Like so:

Eval Script First 10000
Code:
perform hero.assign[Custom.WHATEVER]

Prereq Script
Message "You can only select a single Theme!"
Code:
        ~ If we're a pick, then we are valid, and stop before checking anything further.
        if (@ispick = 1) then
          @valid = 1
          done
          endif

       @valid = 1 - hero.tagis[Custom.WHATEVER]

That would combo well with the stuff you already have. The first theme would be added and then all subsequent ones would be invalid. If the user ignored your warning and added a second Theme anyway, then the mechanic would warn them about having too many.
 
I'll try this out, but I think I may just keep it as originally set up, where it just provides a warning if they don't pick a theme or if they pick more than one. Thanks Aaron!
 
Back
Top