Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Authoring Kit


Thread Tools Display Modes
Join Date: May 2021
Posts: 84

Old February 19th, 2022, 06:27 PM
Does anyone know how to use the setchosen[...] target reference on a menu field?

For example
<field id="someField" name="Example" type="user" style="menu"/>


perform field[someField].setchosen[Component,...?]
I've been able to figure out that the first parameter expects the id of a defined component, and there is at least a second parameter. But so far I've just gotten as far an "Invalid setchosen syntax used" error during compile, and not even any of the potential runtime errors.

Being able to set the value of menu-style user fields would make one thing possible that I haven't found any other solution for (creating a shadowed proxy pick to use with a menu_thing in the UI, and pass on the result to an already existing non-shadowed pick).

It would also help me to clean up some messy scripts/workarounds I've written, since I would be able to use a menu-style field as a simple script-modified linkage.
ploturo is offline   #1 Reply With Quote
Join Date: May 2021
Posts: 84

Old February 25th, 2022, 04:04 PM
I was able to track down an example in a procedure (xactMonSet from pathfinder).

~if we need to select from the list of factions, provide an initial
~selection of the first one that has non-zero prestige to spend
if (empty(hero.transact.field[xactFixFac].text) <> 0) then
     var factexpr as string
     factexpr = "(" & hero.transact.field[xactFacLis].text & ") & (fieldval:facCPA > 0)"
     if (hero.haschild[BaseFact,factexpr] <> 0) then
          perform hero.transact.field[xactFact].setchosen[BaseFact,factexpr,hero]
One thing to note is that the script has to be trusted to be able to change any user field (which all menu-style fields are), otherwise you will sometimes get strange compilation errors. Certain types of scripts are trusted by default (like creation scripts), and otherwise you will need to use a trustme statement.
ploturo is offline   #2 Reply With Quote
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,198

Old February 25th, 2022, 06:10 PM
setchosen could very easily overwrite the user's choices in drop-downs, so it definitely needs to be in a trusted script - using setchosen is a sledgehammer approach, and I don't think I've ever used it except in a creation script, to set a default the user can later change. For most cases where you need to choose a specific thing for the user, assigning an identity tag that says "the thing with this Id was chosen for this menu" and then writing your scripts to first check for that tag, then check if the user made a choice is the better solution for cases like "You gain X as a bonus, but it must choose Y".
Mathias is offline   #3 Reply With Quote

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 02:18 AM.

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