• 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

Checking for an OR pre-req

zarlor

Well-known member
I've been looking at how to handle either/or situations for a pre-requisite and it looks like the best way is with a script. One example I found was for a Blood and Guts edge that has a Message set to "Fighting d10, Shooting d10 or Throwing d10 required." and a Pre-req code of:

Code:
        validif (#traitfound[skFighting] >= 5)
        validif (#traitfound[skShooting] >= 5)
        validif (#traitfound[skThrowing] >= 5)

        if (@ispick <> 0) then
          altpick.linkvalid = 0
          endif

Now it seems to me that the"validif" statements would be all that's needed. Does anyone know what the if statement at the end is for?
 
I think what it does is check for the first one and if found, it valids that pick and ends if not it goes to the alt pick which is the second one and if the second one isn't found moves on to the third, but that is just a guess as to the way it looks to me.
 
Except that it would have already dropped through all of those before getting to the if statement.

It seems instead like the if is if any of those was a valid pick then set "altpick.linkvalid" to 0 otherwise none of the above was satisfied to set that to 1 (or true, if you will.) I guess I'm just not sure what altpick.linkvalid is even supposed to be used for. The wiki is just not clear enough on it for me to figure out why someone would write it this way. I'm just not seeing what was being alternately picked here, I guess?
 
Yes the wiki is a little confusing on how it reads to me, but I'm not really a coder, so I get lost a lot when I go looking for something, All I know is that it works because I used it on one of my edges LOL, though I would like to know why some of this codes work - it would be nice.
 
Well, I've used the validif lines in stuff before without the additional if part and it all seemed to work just fine so that's why I was wondering what the extra if statement was supposed to be for.
 
I may stick with not bothering to add the extra lines then. I suppose if any of us start seeing problems from not using them then that might tell us why someone else had decided to use them. ;)
 
The lines at the bottom provide different handling for "picks" versus "things". If the item is a pick (i.e. has been added to the character by the user), whatever it's linked to is marked as invalid. This causes it to be highlighted in red within the UI.

If the item is a thing (i.e. presented in list for the user to select and add, but not yet added), then the logic is not applied. The reason for this is "altpick" is only supported on picks (what a surprise!), so attempts to use it on a thing will report an error.

So the net effect of the logic is to make sure that any linked pick is properly flagged as invalid and therefore highlighted in red for the user.

Hope this helps!
 
I think I see. So it's likely good practice to add the code for error trapping? I may have to go back and do that one some of my data files, then.
 
Back
Top