Member
Join Date: May 2021
Posts: 84
|
Does anyone know how to use the setchosen[...] target reference on a menu field?
For example Code:
<field id="someField" name="Example" type="user" style="menu"/> ... perform field[someField].setchosen[Component,...?] 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. |
#1 |
Member
Join Date: May 2021
Posts: 84
|
I was able to track down an example in a procedure (xactMonSet from pathfinder).
Code:
~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] endif endif |
#2 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,243
|
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".
|
#3 |
Thread Tools | |
Display Modes | |
|
|