Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Pathfinder Roleplaying Game

Notices

Reply
 
Thread Tools Display Modes
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226

Old December 24th, 2018, 05:23 AM
Hi folks, still having a little trouble understanding how to script a foreach loop, and I'm hoping someone can guide me in the right direction.

I'm creating a class ability that selects from a set of rogue talents. I've identified each valid rogue talent with the tag "abCategory.Inh_tal" I then put in the following eval script:
Code:
foreach thing in Ability where "abCategory.Inh_tal"
     field[usrCandid1].text = splice(field[usrCandid1].text, eachthing.tagids[thingid.?], " | ")
      nexteach
I put in a debug into the script to be sure that all applicable talents where being considered as candidates, which correctly identified all candidates.

But on the class tab, the drop-down menu still shows "Nothing to select". What is my script missing?
Bob G is offline   #1 Reply With Quote
Minous
Senior Member
 
Join Date: May 2015
Posts: 830

Old December 24th, 2018, 09:53 AM
Not sure you are trying to achieve your goal correctly. You probably need to use a candidate expression on said field, not try to muck with values.
Minous 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 December 24th, 2018, 11:55 AM
I assume the issue is that you have the Dropdown setup to use Picks and the Foreach loop is looking at Things. Either change your dropdown to look at Things or change the foreach loop to look at Picks. But currently you have apples looking at oranges and wondering why they don't match.

Another way is to take the dropdown out of the equation and do the following:
Code:
foreach thing in Ability where "abCategory.Inh_tal"
  debug eachthing.idstring
nexteach
Then go to Develop->Floating Info Windows->Show Debug Output. This will open a window that will show you the Thing ID from the above Debug statement.

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
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226

Old December 26th, 2018, 08:30 PM
Quote:
Originally Posted by Minous View Post
Not sure you are trying to achieve your goal correctly. You probably need to use a candidate expression on said field, not try to muck with values.
Hi Minous, I don't think I understand what you mean by a 'candidate expression.' Can you explain a little further?
Bob G is offline   #4 Reply With Quote
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226

Old December 26th, 2018, 08:34 PM
Quote:
Originally Posted by ShadowChemosh View Post
I assume the issue is that you have the Dropdown setup to use Picks and the Foreach loop is looking at Things. Either change your dropdown to look at Things or change the foreach loop to look at Picks. But currently you have apples looking at oranges and wondering why they don't match.

Another way is to take the dropdown out of the equation and do the following:
Code:
foreach thing in Ability where "abCategory.Inh_tal"
  debug eachthing.idstring
nexteach
Then go to Develop->Floating Info Windows->Show Debug Output. This will open a window that will show you the Thing ID from the above Debug statement.
Thanks SC, if I take out the dropdown, what do I do with the Thing ID's? How do I get the user to select one from a valid list of 8 different Things?
Bob G is offline   #5 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old December 27th, 2018, 02:31 AM
Quote:
Originally Posted by Bob G View Post
Thanks SC, if I take out the dropdown, what do I do with the Thing ID's? How do I get the user to select one from a valid list of 8 different Things?
I took the name of the thread to heart and thought you where just trying to see how a Foreach loop worked. Not that you where trying to use it for real.

Let’s start over and tell me what you are trying to do/accomplish and then I will have a better chance to answer with the correct way to solve the issue.

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   #6 Reply With Quote
Bob G
Senior Member
 
Join Date: Nov 2017
Location: Trafford, PA, USA
Posts: 226

Old December 27th, 2018, 03:49 AM
Quote:
Originally Posted by ShadowChemosh View Post
I took the name of the thread to heart and thought you where just trying to see how a Foreach loop worked. Not that you where trying to use it for real.

Let’s start over and tell me what you are trying to do/accomplish and then I will have a better chance to answer with the correct way to solve the issue.
Well, you were right. And I'm using it for real. So, both, really
I'm creating a class ability that asks the user to select from a menu of rogue talents. One selection, made at first level, and done. Seems easy, but the script I wrote above just doesn't find the right items, even though the debug identified the correct candidates.

Thanks for your help. It's very much appreciated.
Bob G is offline   #7 Reply With Quote
ShadowChemosh
Senior Member
Volunteer Data File Contributor
 
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729

Old December 27th, 2018, 04:10 PM
Quote:
Originally Posted by Bob G View Post
Well, you were right. And I'm using it for real. So, both, really
I'm creating a class ability that asks the user to select from a menu of rogue talents. One selection, made at first level, and done. Seems easy, but the script I wrote above just doesn't find the right items, even though the debug identified the correct candidates.

Thanks for your help. It's very much appreciated.
Lets start with the fact that a Script is NOT able to add new options/Things to a character. I am trying to figure out the purpose of this ability in choosing another ability. Right now you have the foreach reading through THINGS. Things are "Read Only" as they exist in the XML data base and do not exist on a character.

So class ability A selects a rogue talent and then does what? You can't add this rogue talent, you can not change any of its values, and its scripts will not fire because its not a Pick.

To cover your current issue your foreach is reading THINGS and your dropdown is setup to look at PICKS. This is why originally you where getting "Nothing to select". To fix this go into your class ability and on the "Item Selection" section change "Restrict First List To..." to be "All Things".

Now your list you generate will be Things and the dropdown will be Things.

To cover one last idea is that you do NOT need a foreach loop to even build a dropdown list. You can add your own "Custom Expression" and the dropdown is built for you.

For the custom expression simply add this:
Code:
component.Ability & abCategory.Inh_tal
Set the list to All Things and the list is built for you.

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   #8 Reply With Quote
Reply

Thread Tools
Display Modes

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 12:40 AM.


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