View Single Post
Duggan
Senior Member
Volunteer Data File Contributor
 
Join Date: Nov 2009
Posts: 1,502

Old February 20th, 2018, 04:29 PM
Back to the effects of one menu dictating the others, currently I have the Role MenuThing setting what the valid choices are for the other two MenuThings with the following bit of code:

Code:
<eval index="1" phase="PreTraits" priority="4500">
  <before name="Calc trtFinal"/><![CDATA[
    var skChoices1 as string
    var skChoices2 as string

    skChoices1 = field[FTRole].chosen.tagids[FTSkChc1.?, " | "]
    skChoices2 = field[FTRole].chosen.tagids[FTSkChc2.?, " | "]
    
    field[availSk1].text = skChoices1
    field[availSk2].text = skChoices2      
  ]]>
  </eval>
However, if a given Role only allows one choice (which most of them do for at least one of the skill choices), I'd like to automatically set the "chosen" to the correct value and if the user changes the Role, and a given setting is no longer valid, I'd like to be able to blank it or set it to the first valid option.

It feels like I should be able to code it kind of like this:
Code:
if (field[FTRole].chosen.tagcount[FTSkChc1.?] = 1) then
  foreach thing in FTSkill where field[FTRole].chosen.tagids[FTSkChc1.?, " & "]
    ~ Should only be the one
    field[skillCh1].chosen = eachthing
    nexteach
  endif
at least for the "only one choice" scenario, but I get an "invalid use of the reserved word 'field' in script" error. I am able to do a debug statement showing that "eachthing.idstring" holds the right values, so I think I'm close to on the right track.
Duggan is offline   #15 Reply With Quote