PDA

View Full Version : Custom Expression resources


Mergon
February 7th, 2016, 08:53 AM
I have a question for you scripter out there.

Does anyone know a resource site on how to create Custom Expressions for Drop Down?

Examples:

1) I want to create a drop down menu to select from a list of all cantrips.

2) I want to create a drop down menu to select from a list of all arcane casting classes.

3) I want to create a drop down menu to select from a list all classes except one class.

4) In the first drop down I pick a attribute score (say Intelligence). In the 2nd drop down I want to pick a 2nd attribute score that cannot be the one selected in the 1st pick.

These are just examples of what I'd liek to do am at a loss to find a resource site that explains how to create such custom expressions . . . :(

Even a list of the more common custom expressions would be much appreciated. I could at least work from that.

Mathias
February 7th, 2016, 11:02 AM
If you don't mind a movie to watch, my Gen Con 2014 seminar was about setting up the expressions to use in dropdowns and in foreach statements: https://www.youtube.com/watch?v=9UPWoih8-q8

ShadowChemosh
February 7th, 2016, 11:19 AM
I think I would be better off to go over how to find the information about Custom Expressions and how to construct your own. You know the old saying 'teach a man to fish'. :) If not already please read over the "Glossary of Terms (http://forums.wolflair.com/showthread.php?t=15524)" so you know the difference between a "Pick" and a "Thing".

A "Custom Expression" is like a "Find" or "Search" feature really. I assume everyone has done one of those. You have a big word document and you want to find the instance of the word "Shadow". You bring up the "find" window and type in Shadow and press "find" and boom you find it or not in the text.

What if you wanted to find only "specific" instances of "Shadow" like say you wanted only the words with the "S" being capitalize. You can click on "Match Case" to find that specific "Shadow" that is capitalize.

Where I am going with all this is that Custom Expression is just like the above but instead you are looking for Specific "Thing" or "Pick" in the Hero Lab database. Not only are custom expressions used for creating a Drop down list but you will need the same logic for foreach loops and findchild[]. Instead of using "words" to do your find/search you instead use "Tags" specifically a Group.Tag. Tags are the building blocks of HL and help to group together specific Things. Please see Aaron's post HERE (http://forums.wolflair.com/showpost.php?p=223429&postcount=3) for more info on how to work with tags in HL.

We can combine multiple tags together using "and" & "or" logic to produce some very complex expressions. In addition Custom Expressions understand the use of brackets just like math. So in math if I said (1 + 1) * 2 = you know the stuff in the brackets is done before the multiplication. HL uses the same logic style.

In HL custom expressions a "and" statement is done with the "&" symbol and a "or" is done with "|" symbol. Another helpful one to know is "not" by using "!". Let me sum that up:

& = and
| = or
! = NOT
( ) = Brackets to control groups


Lets look at some of the ones you wanted:
1) I want to create a drop down menu to select from a list of all cantrips.

How do you find the "Tags" you need to work with? The simplest method is to make a character and add a "Cantrip" to it. Then go to Develop->Enable Data File Debugging. Then on the cantrip where you see the "?" RIGHT mouse click to bring up a new window of options. Select "Show Debug Tags" which will bring up the window of all the "Tags" and "Groups" that exist on the Cantrip.

The first Group.Tag you want to start with is the "most" generic of tags which is the "Component" tags. You then drill down to more "exact" tags as you go to the left. In this case "BaseSpell" is the "base" component that makes up all spells in HL. In other systems we don't have a tag that says "Cantrip" but usually the "Spell Level" is simply 0. So you should see a tag for "sLevel.0" meaning its a cantrip or zero level spell.

Put together you get this:

component.BaseSpell & sLevel.0

The above tells HL to produce a list of Things or Picks that meet the listed expression.

In 5e there is also a "Helper" tag added called "Helper.Cantrip" that could be used to sort the list by instead:

component.BaseSpell & Helper.Cantrip


Lets say we wanted to exclude all the zero level spells from the Cleric Class.

component.BaseSpell & sLevel.0 & !sClass.cHelpClr

We add another "and" with a "NOT" equal to the Spell Class (group id) and the "Class Helper ID for Cleric". Where did I find this tag? I added a Cleric Cantrip and looked at the tags on it.

Mergon
February 7th, 2016, 11:26 AM
If you don't mind a movie to watch, my Gen Con 2014 seminar was about setting up the expressions to use in dropdowns and in foreach statements: https://www.youtube.com/watch?v=9UPWoih8-q8

Mathias:

Watching your video as I type this. Thx.

Mergon
February 7th, 2016, 11:33 AM
ShadowChemosh:

Between Matthias' video and what you just posted these are what I've been looking for.

You are right of course about:

I think I would be better off to go over how to find the information about Custom Expressions and how to construct your own. You know the old saying 'teach a man to fish'. If not already please read over the "Glossary of Terms" so you know the difference between a "Pick" and a "Thing".

What was giving me headaches was trying find the various tags. mathias' video reminded me of the Develop tools . . . <duh>

I had not realized that you could just right click on an item and bring up the tags, fields, etc. that I had been hunting & pecking using the drop downs . . .

Thx to both of you for the help. back to my scripting.

ShadowChemosh
February 7th, 2016, 12:46 PM
2) I want to create a drop down menu to select from a list of all arcane casting classes.
I wanted to add some more information specific to "Classes" and finding the tags. Its a "gotcha" that catches allot of people. I am going to use Cleric in this example.

When you add a Class to HL two "Picks" are actually added at level 1. One of these is called the "Class" and starts with "cCleric" as its Unique ID. This gets added "each" time you take a level and it has only a few values like that levels HP and stuff.

The 2nd Pick that is added is the "Class Helper" and that is added "only" once no matter what level your cleric is. These Class Helpers always have a unique id of "cHelpXXX" where XXX is the 3 letter abbreviation for the class. This helper has 99% of the class information you will want. If you right click on the "Class" tab and look at Tags you will be looking at the Class not the Class Helper.

To correctly look at the tags on the Class Helper you must go to Develop->Floating Info Windows->Show Selection Tags. Then on the new window at the top type in cHelp.

To find only Arcane class add a Arcane class (ie Wizard) and look at the Class Helper for its tags. In this case I would type in the top left "search" box for "Arcane" and see what tags appear:
4394

With the above info you can construct the Expression. Remember to start with a component.

component.Class & CasterSrc.Arcane