Thread: d6 Star Wars
View Single Post
thedarkelf007
Senior Member
 
Join Date: Jun 2011
Location: Canberra, Australia
Posts: 624
Send a message via MSN to thedarkelf007 Send a message via Yahoo to thedarkelf007

Old August 24th, 2011, 07:18 PM
Thanks for the reply Mathias.

here is what I eventually had to do to get the code to work with adding a +0 on the end of the string which I was trying to avoid.

The commented out if statement below does not work with var's using in the while statement. I am not sure why.

This is derived from the Savage Worlds example.

So far I am liking what I am seeing and hope to have a basic Star Wars build ready by the end of September. I already have a good start on Attributes, Skills and Races.

Code:
      <eval index="3" phase="Render" priority="5000" name="Calc trtDisplay">
        <after name="Calc trtFinal"/><![CDATA[
        ~if this is a derived trait, our display text is the final value
        if (tagis[component.Derived] <> 0) then
          field[trtDisplay].text = field[trtFinal].value
          done
          endif
          
        ~bound our final value including in-play adjustments
        var dValue as number
        dValue = 0
        var final as number
        final = field[trtFinal].value
        while (final > 2)
          dValue += 1
          final -= 3
          loop
        
        debug "dValue = " & dValue & " and final = " & final
        ~covert the final value for the trait to the proper die type for display
        var dievalue as string
        dievalue = dValue & "D+" & final
        ~if (final <> 0)
        ~  dievalue &= "+" & final
        ~  endif
           
        ~put the final result into the proper field
        field[trtDisplay].text = dievalue
        ]]></eval>
thedarkelf007 is offline   #4 Reply With Quote