Lone Wolf Development Forums Conditional && and ||
 User Name Remember Me? Password
 Register FAQ Members List Search Today's Posts Mark Forums Read

 Notices 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

 Thread Tools Display Modes
Junior Member

Join Date: Mar 2015
Posts: 5

October 14th, 2017, 08:45 PM
I found the post that spelled out how to perform logical comparisons, but I cannot find how to perform AND and OR statements to combine booleans in an IF statement. Can anyone provide an example or a link to a good tutorial with an example of && and ||?
#1
Senior Member
Lone Wolf Staff

Join Date: May 2005
Posts: 12,393

October 15th, 2017, 10:27 AM
What do && and || mean? You'll never see a doubled character as a operator in HL's scripting language. Do you just mean & and |, and you're pulling in terms from another language?

Also, do you want to use booleans with a script, or are you using booleans in a tag expression? The answer is different in each case

If your question is about tag expressions, here's that section of the wiki: http://hlkitwiki.wolflair.com/index....ag_Expressions

For scripts, you'll have to be clever with addition and subtraction and multiplication, because the standard if () then can't take booleans.

But,

if (A + B <> 0) then

ends up meaning A or B, as long as both A and B are things that are false at 0 and true if <> 0, and

if (A + B = 2) then

ends up meaning A & B, as long as both A and B are things that are false at 0 and true at 1 (but in this case, it doesn't work if they can be values > 1).
#2
ShadowChemosh
Senior Member
Volunteer Data File Contributor

Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,552

October 15th, 2017, 12:15 PM
Quote:
 Originally Posted by Mathias What do && and || mean? You'll never see a doubled character as a operator in HL's scripting language. Do you just mean & and |, and you're pulling in terms from another language?
Basically yes. && = "and" and || = "or" in other languages outside of HL (PHP is one off the top of my head). Usually when & is used as contraction function for strings the language uses && to represent a logical IF "and".

FYI ISO standards for SQL uses || to concatenate strings together. The fun of working in many different languages.

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
Junior Member

Join Date: Mar 2015
Posts: 5

October 16th, 2017, 04:25 AM
Suppose I have a numeric variable "delta" and I want to test to see if it is within a given range:
Code:
```if (delta > 3 AND delta <=6) then
do stuff
endif```
What should I be using in HL instead of AND?

Suppose I want to know if delta is one of two values:
Code:
```if (delta = 3 OR delta = 6) then
do stuff
endif```
What should I be using in HL instead of OR?
#4
Senior Member
Volunteer Data File Contributor

Join Date: Nov 2009
Posts: 1,224

October 16th, 2017, 07:21 AM
For AND
Code:
```if (delta > 3) then
if (delta <=6) then
~ do stuff
endif
endif```
For OR (can result in duplication if doing "do stuff" twice has different effects than running it once)
Code:
```if (delta = 3) then
~ do stuff
endif

if (delta =6) then
~ do stuff
endif```
Alternately, if you can turn it into a tag check (including a tag value check), things get more flexible.
#5
rlane187
Junior Member

Join Date: Mar 2015
Posts: 5

October 16th, 2017, 11:27 AM
Quote:
 Originally Posted by Duggan For AND Code: ```if (delta > 3) then if (delta <=6) then ~ do stuff endif endif``` For OR (can result in duplication if doing "do stuff" twice has different effects than running it once) Code: ```if (delta = 3) then ~ do stuff endif if (delta =6) then ~ do stuff endif``` Alternately, if you can turn it into a tag check (including a tag value check), things get more flexible.
I would love to use tags for it, but it is calculating how many creation points the user is burning on attributes during creation.

To summarize the takeaway from this, I need to nest any if statements for logical AND or OR?
#6
Senior Member
Lone Wolf Staff

Join Date: May 2005
Posts: 12,393

October 16th, 2017, 12:01 PM
Depending on how things are stored, tagexpr may work:

Code:
`if (tagexpr[(fieldval:trtUser >= 3) & (fieldval:trtUser <= 6)] <> 0) then`
#7

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Lone Wolf Development Web Site Announcements Realm Works Forums     Realm Works Discussion         Realm Works in Action         Realm Works Feature Requests     Realm Works in Action     Realm Works Feature Requests Hero Lab Online Forums     Hero Lab Online Discussion     HLO - Pathfinder Playtest     HLO - Starfinder Hero Lab Forums     HL - Pathfinder Roleplaying Game     HL - D&D 5th Edition SRD     HL - Shadowrun     HL - Mutants & Masterminds     HL - d20 System     HL - World of Darkness     HL - Call of Cthulhu     HL - 4th Edition     HL - Savage Worlds     HL - Cortex System     HL - Authoring Kit     HL - User Projects     HL - Alternity (user-created)     Hero Lab Discussion Army Builder Forums     Army Builder Army Builder Data Files     Babylon 5: A Call to Arms     Battlefleet Gothic     Blood Bowl     Black Powder, Bolt Action, Hail Caesar, Judge Dredd, and Pike & Shotte     Confrontation - English     Kings of War (2nd Edition)     Lord of the Rings (Tabletop)     Mordheim     Necromunda     Starship Troopers     Star Wars: X-Wing and Armada Miniatures Game     The 9th Age     Warhammer Ancient Battles     Warhammer 40,000     Warhammer Fantasy 8th Ed.     Warhammer Historical: The Great War     Warhammer Fantasy 3rd Ed.     Warlord     Warmachine & Hordes     Warmaster Card Vault Forums     Card Vault Card Vault Data Files     MLB Showdown     Lord of the Rings CCG     .hack//ENEMY     Vs. System     Yu-Gi-Oh!     D&D Miniatures

All times are GMT -8. The time now is 09:32 AM.

 -- Default Style -- Majestic Contact Us - Lone Wolf Development Forums - Archive - Top

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