View Single Post
Aaron
Senior Member
 
Join Date: Oct 2011
Posts: 6,793

Old November 7th, 2017, 02:19 PM
You can call it from an action script and then store it in a persistant user field with each button press. Here is an example of a button we use in PF.

Code:
    <portal
      id="actRoll"
      style="actBig">
      <action
        action="trigger">
        <trigger><![CDATA[
          ~make sure we're rolling a valid number of dice
          var iserror as number
          if (herofield[tSCRNumDce].value < 1) then
            iserror = 1
            endif
          if (herofield[tSCRDceSiz].value < 1) then
            iserror = 1
            endif
          if (herofield[tSCRMult].value < 0) then
            iserror = 1
            endif
          if (herofield[tSCROver].value > 0) then
            iserror = 0
            endif

          if (iserror <> 0) then
            notify "Sorry, no starting cash roll has been specified for this class."
            done
            endif

          ~for each die, generate a random number and add it to the total
          var i as number
          var basecoin as number
          for i = 1 to herofield[tSCRNumDce].value
            basecoin += random(herofield[tSCRDceSiz].value) + 1
            next
          basecoin *= herofield[tSCRMult].value
          basecoin += herofield[tSCRBonus].value

          if (herofield[tSCROver].value <> 0) then
            basecoin = herofield[tSCROver].value
            endif

          ~update the starting cash
          ~first reset the existing fields.
          herofield[tStartCP].value = 0
          herofield[tStartSP].value = 0
          herofield[tStartGP].value = 0
          herofield[tStartPP].value = 0

          herofield[tStartCn1].value = 0
          herofield[tStartCn2].value = 0
          herofield[tStartCn3].value = 0
          herofield[tStartCn4].value = 0

          ~ Depending on which slot we have chosen, the base coin differs
          if (hero.childfound[Currency].field[curBaseSlt].value = 8) then
            herofield[tStartCn4].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 7) then
            herofield[tStartCn3].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 6) then
            herofield[tStartCn2].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 5) then
            herofield[tStartCn1].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 4) then
            herofield[tStartPP].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 3) then
            herofield[tStartGP].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 2) then
            herofield[tStartSP].value = basecoin
          elseif (hero.childfound[Currency].field[curBaseSlt].value = 1) then
            herofield[tStartCP].value = basecoin
            endif
          ]]></trigger>

        <buttontext><![CDATA[
          ~it's only a "roll" if we don't have a fixed override value for our cash
          if (herofield[tSCROver].value <> 0) then
            @text = "Set Cash"
          else
            @text = "Roll"
            endif
          ]]></buttontext>
        </action>
      </portal>
Aaron is offline   #8 Reply With Quote