• 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

AND/OR statements, conditional logic and scripting commands

TobyFox2002

Well-known member
Well, I know its not been long since my last question, and I don't want to seem like one who comes running for every question but the documentation on some of these is just a bit lacking. I love Hero Labs but the the Editor Help files just seems like it has more holes in it than aged Swiss Cheese.

That being said, I have some (hopefully) easy questions that should help me piece things together on my own.

First, I have from time to time seen code like this, it doesn't really seem to affect things as far as I can see:
Code:
~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)

Second, is there a way to perform traditional boolean tests in if statements.
Sure I suppose I could do nested if statements but that is a great deal more clumsy than saying:
Especially if you are checking for prerequists to a feat or trait (Regional feats from faerun as an example that require different races to be from different regions.)
Code:
if (ab = 0) AND (xyz = 0) then
   YAY!
endif

Third, finding thingids or whatever you'd want to call them for things like flight, its nowhere. All I could find was:
Code:
xfly

And that didn't really give me enough information to base anything on, such as scripts that change flight speed and maneuverability categories based on feats. Not that it probably helps much since only base land speed is shown on the printout which is a shame. But I still would like to be able to view and alter flight speed and maneuverability.

Third and finally, for now; the difference between showing having a special ability hidden from the list and having it disabled entirely. How is either done, or what can I look at to see as an example of both.

I have a million other different questions, but I think they all stem back to me not being able to see how to ask for certain information. And the Develop > Show Floating Windows > Show Selection Fields only gives so much info. Altering the attack penalties of main and offhand weapons individually to name only one example.

I will try not to be a pest and reserve some of my other questions until I know enough about how things work to understand the answer =p.

Thank you in advance.
 
Last edited:
Well, I know its not been long since my last question, and I don't want to seem like one who comes running for every question but the documentation on some of these is just a bit lacking. I love Hero Labs but the the Editor Help files just seems like it has more holes in it than aged cheese.

That being said, I have some (hopefully) easy questions that should help me piece things together on my own.
.
.
.
.
Third, finding thingids or whatever you'd want to call them for things like flight, its nowhere. All I could find was:
Code:
xfly

And that didn't really give me enough information to base anything on, such as scripts that change flight speed and maneuverability categories based on feats. Not that it probably helps much since only base land speed is shown on the printout which is a shame. But I still would like to be able to view and alter flight speed and maneuverability.

Third and finally, for now; the difference between showing having a special ability hidden from the list and having it disabled entirely. How is either done, or what can I look at to see as an example of both.

I have a million other different questions, but I think they all stem back to me not being able to see how to ask for certain information. And the Develop > Show Floating Windows > Show Selection Fields only gives so much info. Altering the attack penalties of main and offhand weapons individually to name only one example.

I will try not to be a pest and reserve some of my other questions until I know enough about how things work to understand the answer =p.

Thank you in advance.

You aren't being a pest, so don't worry about that. I'm currently on a computer that doesn't have HL, so my answers may not be complete.

First:
Code:
~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)

This means that if the tag "Helper.ShowSpec" appears on the thing this eval script is written on, then nothing after this line is processed. It's short-hand for "If this is true, don't do anything else below this line".

Second:
Code:
if (ab = 0) AND (xyz = 0) then
   YAY!
endif

Would typically be written:
Code:
if (ab + xyz = 0) then
  YAY!
endif

If you need examples, I can provide them the next time I am sitting in front of HL (probably Monday)

Third, there are a couple ways to find the thingid. One is to use new(copy), though admittedly that doesn't always work. Another is to right-click on something in the portfolio and show either tags or fields. The id will appear at the top of that window. If you have the community set, you can take a look at xfly2, and I think that will tell you a lot about how to modify fly. If not, I can provide some options on monday (unless someone else jumps in in the meantime).

Fourth, I don't think there's a real disable option. There might be a Disable tag, but I'm not sure its as complete as you want.
 
First:
Code:
~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] = 0)

This means that if the tag "Helper.ShowSpec" appears on the thing this eval script is written on, then nothing after this line is processed. It's short-hand for "If this is true, don't do anything else below this line".

Wouldn't that be "if the tag does not appear" as the value for the tagis is 0 ? :)

LM (creeping back from the dead)
 
You can't really do AND/OR expressions except with regards to tags, in which you can use the tagexpr function, which works as follows:

Code:
if (tagexpr(Hero.Arcane & Hero.Divine) then 
...
endif

This would check if the hero had both an Arcane spellcaster tag and a Divine spellcaster tag. There is also the OR equivalent (Hero.Arcane | Hero.Divine).

My suggestion, when it comes to things that are not tags, is to use nested if then else statements for the logical statements. You will often find that tags are not available, or are not enough, for using tagexpr.
 
Kendall,

You can add values together. If together they equal 0 then they are both 0 (generally). Something like:

Code:
field[?].value + field[?].value = 0

It's not a great choice for everything, but can work in a lot of cases.
 
tagexpr can also look at fields, Kendall DM. For example:

Code:
      if (tagexpr[component.Ability & SpecType.Aura & (fieldval:abValue > 0 | fieldval:abRange > 0 | fieldval:abDC > 0)] <> 0) then

Main limitation is that it can't look at fields on OTHER picks. Only on itself, just like bootstrap conditions
 
I have gotten very very lost, very very quickly. The below answer is great and I'm sure it does answer some part of what I want but I cant see how, it assumes a higher level of understanding.

Code:
     if (tagexpr[component.Ability & SpecType.Aura & (fieldval:abValue > 0 | fieldval:abRange > 0 | fieldval:abDC > 0)] <> 0) then

Totally lost.. Wish there was a doc out there that explained each part of it so.. I didnt have to keep coming back here, every time I find a reply I've had to stop because I've reached the limit of what I can do without help. And I just get more questions.

Sorry.

I don't know the language and I want to learn it,
 
Maybe if you gave us an idea what exactly you are trying to do, and we can be a bit more expansive on how to get it done. There are documents out there to help you, which can be accessed from the Help menu selection (both for HL itself and its Editor). I found most of the intricate programming language techniques from there or from the Authoring Kit Wiki. Try looking through the links on the Help menu and see if that gets you any further along.

To explain a little about the above. Essentially, things in HL can have tags associated with them, which are part of a component and the component tag (such as the Hero component, and the Arcane tag). Tags can be found on different items in HL, some are on the Hero itself, and some are on the things that compose the Hero (such as feats, weapons, etc.), and these oftentimes have something that occurs 'behind the scenes', such as the Helper.ShowSpec, which does not show the Specials if this tag is not present (in the Editor, this is assigned when you check the Show In Specials checkbox). Everything that is a thing in HL also has a series of fields, which usually can be manipulated to get things to do as you like. Then there is timing, which is a whole other issue, where timing is the order in which things are processed (abilities should be processed before the final attack value is determined, level should be determined before assigning the class abilities, etc.), and these are highly variable and not always clear.

Also, if you select the Develop menu, you can look at all the things, with the tags, fields, and timing associated with them, through the Floating Info Windows. I would also rely heavily on the Forum, doing a search to find things similar to what you are trying to do, you might find someone who has already answered the issue. Lastly, the community files have a ton of stuff you can look at to see how things get scripted.

Hope this was more helpful.
 
Last edited:
I've looked at the help files that come with the editor, and they are nice, they get you started, but it does not list all of the macros. Perhaps the authoring wiki does. I will look at that, I assumed it was for creating a custom campaign (ie, different base system like the Spirit, Mind, Body, three stat system).

As for what I wanted to do with this specifically, learn from it. I've already gotten myself started with some of the basics by just JUMPING in.. I made a copy of the races of the dragon compile and went to town adding all of the feats (except the ones that are also in the complete arcane), all of the spells.

For learning races, I made a new .user file and made an Araviel (winged elf from races of faerun). I next went to try and do some more complicated things, handling Races and Regions and bonus feats/gear granted by such, as listed in players guide to faerun

It may seem like I jump around but that's because I learn best by doing what I use most and will get the most value from.

The question I was asking about in this thread was how to handle regions. I wanted to check:

Code:
if (race AND region) then
   give hero feat xxx
   give hero xxx starting item
   give hero xxx regional bonuses
endif

The help that I have gotten so far, and what I have learned about HL has made me realize it might be better not to treat all of the regions as a whole, but treat them as separate regions and require prerequisites to obtaining them. The problem with that is different races get different bonuses from each region. However, once I have one made I'll have a blueprint for the rest. And I'll have a better understanding of the code require.

I will try to be more thorough with my questions in the future.

Btw, if your interested in the copy of races of the dragon, I'd be happy share it, its far more complete than the one in the Lawful_g pack.

Thank you, I know I'm a difficult student, I jump around.
 
First, you will have to have a way to assign a character a Region, and then somehow assign a tag to that character. If the Region component doesn't exist, you will have to create a User tag in a thing you create for each Region. Once a character selects the Region, it will have a script to assign the User.Regionxxx (or whatever) to the Hero.

From there you will have to kind of work backwards. Once a character selects a Region, the Region should give the Hero all available feats and starting items (as a bootstrap), then you will have to exclude each according to Race. So your bootstrap has to have the particular Race checked against on the Condition... of the bootstrap. If that Race is present on the Hero, it gets the bootstrap, otherwise is excludes it.

Start with some script for the bonuses:
Code:
if (tagis[Race.xxx] <> 0) then
  ~ Give this races bonuses, use Listen in this example.
  #skillbonus[kListen] += 2
elseif (tagis[Race.xxx] <> 0) then
  ~ etc.
endif

Now the Region will give the appropriate bonuses based on the Race. So, let's say Region is called Somewhere, so the Somewhere special has the above script, and let's say it gives Humans the Improved Initiative feat and an Arquebus, and Elves from there get Combat Casting and an Hourglass. With that as the example, Somewhere will have 4 bootstraps, both feats and both equipment, except the bootstraps for Humans will have Race.Human in it's Condition... while the Elves will have Race.Elf is its Condition..., so you get the idea.

This should be able to do what you want, you just need to make a way to add the choice of Region to characters. That's a bit trickier to accomplish, for that you need a chooser where you would look for choices that included the User.Region? (yes, with the question mark, it acts as a wildcard, but can only apply to ends of tags) tag, and you'll be able to choose from a list of Regions (there should be some examples of this in the community files and the forums). Chooser are far and between though, I always end up using a Feat for it. The other options are Class Specials (which don't apply here) and Custom Abilities (which also work with classes well, and not much else). So use a feat, call it Region: xxx where xxx is the chosen region. It's a bit more complex than this, but that is what I would try diving in with. It's a bit of coding that will require thinking a little backwards, but it is really one of the few ways to assign bootstraps to based on a choice.

Hope that is helpful.
 
I have a way to give regions. I'm going to have each region as a trait. Have the script you gave me test if they are those races and use the trait to give the choice of gear AND be the requirement to regional feats.

Not exactly sure if that's the best way to do it, but it's simple and it prevents things from turning into a mess. Now I just need to create some of the feats and create my first one and once that's working the rest should be cake.

What you gave me was a help, thank you.

P.S., Did you ever finish your Monster Advancing scripts, you talked about (http://forums.wolflair.com/showthread.php?t=14023&highlight=advancing+monsters ) Or did you stop after animal and elemental?
 
Yes, I did. I've got a complete system in place using two adjustments, and so far everything has worked out fine (I haven't touched that code in months and my advancements have been working without a hitch thus far).

The thing is though, each creature needs to have code to handle the advancement of hit dice if they have some other special thing specific to them (such as dragons, which get specific powers or abilities based on HD). I ended up standardizing many of the abilities and powers of monsters so I could reuse them without having to create new ones for each creature (excepting those things which are specific to a single creature), and I have well over 1000 creatures in HL for my game.
 
Last edited:
Wonderful, I'm glad its possible to do. I'll have to see if I can piece it into my monsters somehow, would save time certainly.

The code you gave me did help me come up with a way, but I realize that the way it works doesnt have every race for every region so I was thinking instead I could do it similar to:

Code:
~ Pre-reqs code to check if either or are there, if isRace is equal to 1 then it meets the pre-reqs
var isRace as number
isRace = 0

if (tagis[Race.Human <> 0) then
   isRace += 1
elseif (tagis[Race.HalfElf <> 0) then
   isRace += 1
endif
validif (score >= 1)
~ invaid target container reference syntax used, gah...

OR this as an Expr-req

Code:
tagis[Race.Human] | tagis[Race.HalfElf] <> 0

But neither of those seem to work.

And use them as prerequists to have obtain a Trait then the trait as a prerequisit for the feats.

For example Aglarond (Regional), would require you to be a human or half-elf. Then use the trait as a requirement for the feats. From there all you need to do is say that if you have as a regional feat you can only pick one. The bootstrap for the equipment and bonus languages can be done from the trait, or added in manually, (would probably need to be done manually since its a choice.)
 
Facepalm...

I've been trying to get the code to work for half the day, and that was my problem... how could I have possibly missed that..

I feel like such an idiot.
 
If both those races are getting the same bonuses, you can just use the tagexpr instead, since both of these are tags you are comparing against.

Code:
if (tagexpr[Race.Human | Race.HalfElf] <> 0) then
   ~ do stuff
endif
 
Facepalm...

I've been trying to get the code to work for half the day, and that was my problem... how could I have possibly missed that..

I feel like such an idiot.

The error message I think you're quoting at the bottom of your code is one that should be listed with a line number. Hopefully the line numbers will point you to where in your code the problem lies.

Also, for future reference, you can right-click error messages in Hero Lab and copy them, so that you can paste them here exactly.
 
So thats how doing it like that would work... I switched to the arthitmatic if statement when
Code:
 if (tagis[Race.Human] | tagis[Race.HalfElf] <> 0) then
     ...
 endif

Failed to work, well that is pleasant now.. and easier, unfortunately I'm beginning to realize how tricky this is is going to be.

And, now I come to understand that that I don't know how to build the if statements. At all, the limitation of learning by code examples. I examined the authoring wiki, and well my eyes kinda glaze over after the first half-dozen words. Without it showing me what it means.. I get lost. I mean I can see what I want to use (Development > Show Floating Windows > Show Fields) But not how to build them into a statement.)

tagis[Race.Human] or tagis[Classes.Sorcerer] works but other things such as checking for traits or specials do not. I understand that this is a matter of syntax and probably a matter of learning the different between a thing.

But that aside, the next step is trying to if they have a particular race, and then trait.
 
Back
Top