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

Old August 20th, 2017, 04:02 PM
So, this may be a gimme thing, but I'm implementing the optional bits in the Planet Mercenary background and Command Packages where a given Command Package might have "+2 to Inspire or Entertain". I copied the code from 4E and how they allow races to apply a bonus to one ability for another, but I couldn't understand their "BuildLast" sort set, so I left it blank initially. Except... that means that the items rearrange as I fill in values to alphabetize by the chosen skill. Is there a good way to have it sort by the order I added the items so that they don't rearrange themselves? This is the relevant code:

Quote:
<!-- Skill Bonus portal. Used to list skill bonuses from backgrounds, races, and
command packages, and to allow for choices. -->
<portal
id="raFeatures"
style="tblInvis"
width="240">
<table_fixed
component="UserSelect"
showtemplate="MenuSlPick"
showsortset=""
alwaysupdate="yes">
<list><![CDATA[
(!User.NeedChosen | Helper.ChosenOpt)
]]></list>
<headertitle><![CDATA[
@text = "Skill Bonuses"
]]></headertitle>
</table_fixed>
</portal>
Quote:
<template
id="MenuSlPick"
name="Configurable Pick"
compset="UserSelect"
marginhorz="5"
marginvert="3">

<portal
id="name"
style="lblLeft"
showinvalid="yes">
<label
ismultiline="yes"
field="name">
</label>
</portal>

<portal
id="thinglist"
style="menuSmall">
<menu_things
field="usrChosen1"
component="none"
candidatefield="usrCandid1"
usepicksfield="usrSource1"
maxvisible="10"
sortset="explicit">
</menu_things>
</portal>

<position><![CDATA[
~set up our height; our width is pre-initialized for us
height = portal[thinglist].height

~if this is a "sizing" calculation, we're done
doneif (issizing <> 0)

~position our tallest portal at the top
portal[thinglist].top = 0

~center the other portals on the tallest one
perform portal[name].centeron[vert,thinglist]

portal[name].left = 0
portal[name].width = 100

portal[thinglist].left = portal[name].right + 3
portal[thinglist].width = width - portal[name].width - 3
]]></position>

</template>
Quote:
<!-- SkillBonus component -->
<component
id="SkillBonus"
name="Starting Skill Bonus"
autocompset="no"
panellink="basics">

<!-- This tag is added to the hero if our feature is selected. -->
<identity group="HasFeature"/>

<!-- All feats get the same tag for sorting purposes -->
<!--tag group="SpecialTab" tag="RaceFeat"/-->

<!-- Activate any selected build option -->
<eval index="1" phase="Setup" priority="100" name="Build option activated"><![CDATA[
if (field[usrChosen1].ischosen <> 0) then
if (field[usrChosen1].chosen.ispick <> 0) then
perform field[usrChosen1].chosen.assign[Helper.ChosenOpt]
endif
endif

~forward our "has feature" tags to the hero so it knows we're present
perform forward[HasFeature.?]
]]></eval>

</component>
Quote:
<!-- Skill Bonuses -->
<compset
id="SkillBonus">
<compref component="SkillBonus"/>
<compref component="UserSelect"/>
<compref component="SpecialTab"/>
<compref component="Custom"/>
</compset>
Quote:
<!-- Any background, command package, or race can bootstrap this, adding
SkillBonus.attrid tags as necessary -->
<thing
id="fRPlusSk"
name="+2 to Skill"
compset="SkillBonus"
description="Gives a +2 bonus to the selected skill.">
<fieldval field="usrCandid1" value="component.Skill"/>
<tag group="Hide" tag="Special"/>
<eval index="1" phase="PreTraits" priority="5000">
<before name="Calc trtFinal"/><![CDATA[
~build the candidate expression out of our SkillBonus tags
if (tagis[SkillBonus.?] <> 0) then
field[usrCandid1].text &= " & (" & tagids[SkillBonus.?, " | "] & ")"
endif

~#traitbase[field[usrChosen1].chosen] += 2
perform field[usrChosen1].chosen.field[trtBase].modify[+,2,"Background"]
]]></eval>
</thing>

Yes, I know that I need to modify the logic here so that the items with only one choice don't display a list.

Quote:
<thing
id="bckEnter"
name="Entertainer"
compset="Bckgrnd"
isunique="yes"
description="Maybe you played in a band. Maybe the band was a circus. Maybe the circus was the writing pit for a comedy show.{br}{br}{b}Bonus Skill Ranks:{/b} +2 Athletics {i}or{/i} Empathy, +2 Deceive {i}or{/i} Thrown Weapons, +2 Inspire">

<tag group="SkillBonus" tag="skDodge"/>

<bootstrap thing="fRPlusSk">
<autotag group="SkillBonus" tag="skAthlete"/>
<autotag group="SkillBonus" tag="skEmpathy"/>
</bootstrap>

<bootstrap thing="fRPlusSk">
<autotag group="SkillBonus" tag="skInspire"/>
</bootstrap>

<bootstrap thing="fRPlusSk">
<autotag group="SkillBonus" tag="skThrown"/>
<autotag group="SkillBonus" tag="skDeceive"/>
</bootstrap>


<!-- Define any script needed to apply changes to traits or other mechanisms-->
<eval index="1" phase="Setup" priority="4000"><![CDATA[
~#traitbase[skDodge] += 2
~#traitbase[skMedic] += 2
~#traitbase[skXeno] += 2
~#traitbase[skPistol] += 2
]]></eval>

</thing>
Duggan is offline   #1 Reply With Quote