Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Pathfinder Roleplaying Game
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
GodPole
Member
 
Join Date: Feb 2010
Location: Charlotte, NC
Posts: 81

Old July 3rd, 2011, 06:25 AM
I'm in the process of writing a pretty extensive script that requires the use of Boolean "ands" (&) inside conditional statements:

If (a=1) & (b=2) then...

...and so forth.

I found in a rather old post that this was on the roadmap, but not a high priority.

Is this still the case?

Use of an "&" inside a conditional is throwing errors in the latest version of HL.


I would rather not have to write a bunch of nested if-then statements if I don't need to.

Any help on this is greatly appreciated.

Thanks.

-GP
GodPole is offline   #1 Reply With Quote
Kendall-DM
Spy
 
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220

Old July 3rd, 2011, 09:06 AM
For the moment, there are no boolean operators inside of conditional statements. It is a shame, because I too have needed them and resorted to nested conditionals to get the job done.
Kendall-DM is offline   #2 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old July 3rd, 2011, 10:24 AM
You can do Boolean with OR, AND, but not AND & OR. A good number of HL scripts do this already.

For OR logic you simply add the variables together and if the total is 1 or higher then DO.

If you wanted Boolean AND logic where all the testes are TRUE then again you can do this. Add the results together and test against the total number of tests. So three Boolean AND logic would test against 3.

But yea if you want to do Boolean AND & OR logic in the same IF statement you can't currently. At least I have not seen how.

Hero Lab Resources:
Pathfinder - d20pfsrd and Pathfinder Pack Setup
3.5 D&D (d20) - Community Server Setup
5E D&D - Community Server Setup
Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources.
Created by the community for the community
- Realm Works kickstarter backer (Alpha Wolf) and Beta tester.
- d20 HL package volunteer editor.
ShadowChemosh is offline   #3 Reply With Quote
rob
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 8,232

Old July 3rd, 2011, 02:02 PM
There is no current support for traditional boolean logic within conditionals. However, the vast array of boolean tests within conditionals comprise testing two or more tag behaviors. Tests of tags can be readily combined in a variety of ways using pseudo-boolean and proper boolean operations. For example....

If you want to see if a pick has both TagA and TagB, you can use the notation below:
Code:
if (pick.tagis[group.TagA] + pick.tagis[group.TagB] >= 2) then
If you want to see if a pick has either TagA or TagB:
Code:
if (pick.tagis[group.TagA] + pick.tagis[group.TagB] > 0) then
If you want to check for one tag but not the other:
Code:
if (pick.tagis[group.TagA] + !pick.tagis[group.TagB] >= 2) then
For an XOR combination:
Code:
if (pick.tagis[group.TagA] + pick.tagis[group.TagB] = 1) then
You can also build a complex tag expression with boolean logic and test for that:
Code:
if (pick.tagexpr[group.TagA & !group.TagB] > 0) then
You can even check tags using wildcards:
Code:
if (hero.tagexpr[!Hero.Creature & Hero.Faction?]) then
Just about everything within Hero Lab is built around and upon tags. The reason for that is simple: tags provide a great deal of flexibility and are extremely efficient internally. It's quite easy to leverage tags in a wide array of boolean operations without the need for more traditional boolean operators. So we haven't added that to the language yet.

Please give the above examples a try and see if they might work for your needs. There are also a lot of other ways that tags can be leverage that follow in the same vein as the examples I gave. If you have a question about how to accomplish a particular objective that seems like it should leverage boolean logic, post it and some of us can help out with how best to structure it. I'm sure there are some cases where nested "if" statements will be required, but they shouldn't be needed all that often if you're leveraging tags.

Hope this helps....
rob is offline   #4 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old July 3rd, 2011, 03:13 PM
Quote:
Originally Posted by rob View Post
You can also build a complex tag expression with boolean logic and test for that:
Code:
if (pick.tagexpr[group.TagA & !group.TagB] > 0) then
You can even check tags using wildcards:
Code:
if (hero.tagexpr[!Hero.Creature & Hero.Faction?]) then
Hope this helps....
Oh nice didn't know about these. Thanks Rob.

Hero Lab Resources:
Pathfinder - d20pfsrd and Pathfinder Pack Setup
3.5 D&D (d20) - Community Server Setup
5E D&D - Community Server Setup
Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources.
Created by the community for the community
- Realm Works kickstarter backer (Alpha Wolf) and Beta tester.
- d20 HL package volunteer editor.
ShadowChemosh is offline   #5 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:31 PM.


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