Member
Join Date: Feb 2010
Location: Charlotte, NC
Posts: 81
|
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 |
#1 |
Spy
Join Date: Jan 2011
Location: Van Nuys, California
Posts: 1,220
|
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.
|
#2 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
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. |
#3 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 8,232
|
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 Code:
if (pick.tagis[group.TagA] + pick.tagis[group.TagB] > 0) then Code:
if (pick.tagis[group.TagA] + !pick.tagis[group.TagB] >= 2) then Code:
if (pick.tagis[group.TagA] + pick.tagis[group.TagB] = 1) then Code:
if (pick.tagexpr[group.TagA & !group.TagB] > 0) then Code:
if (hero.tagexpr[!Hero.Creature & Hero.Faction?]) then 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.... |
#4 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
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. |
#5 |
|
|