Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Remembering long variables

Using sugarcube.
I have code that is generated by many random arrays that is then displayed as
<h3>Character Name:<<print $name>> <<print $surname>>
Human <<print $class>></h3>Alignment:<<print $align>> Speed:<<print $speed>>
Age:<<print $age>> Height:<<print $sh>>' <<print $si>>"
Hit Points:<<print $hp>> ArmorClass:<<print $armor>>(<<print $dexmod>>)
<h3>Abilities</h3>Strength: <<print $str>> (<<print $strmod>>)
Dexterity: <<print $dex>> (<<print $dexmod>>)
Constitution: <<print $con>> (<<print $conmod>>)
Intelligence: <<print $int>> (<<print $intmod>>)
Wisdom: <<print $wis>> (<<print $wismod>>)
Charisma: <<print $cha>> (<<print $chamod>>)
<h3>Weapon</h3><<print $weapon>>
<h3>Proficiencies</h3>Bonus:<<print $profbonus>>
Armor:<<print $armor>>
Weapons:<<print $proweap>>
Tools:<<print $protool>>
Saving Throws:<<print $st>>
Skills:<<print $skill1>>, <<print $skill2>>
Features:<<print $features>>
Racial Traits:<<print $traits>>
Languages:<<print $language>>
Spells:<<print $clerspell1>>, <<print $clerspell2>>
Cantrips:<<print $can1>>, <<print $can2>>, <<print $can3>>
<h3>Equipment</h3><<print $item1>>, <<print $item2>>, <<print $item3>>, <<print $item4>>, <<print $item5>>">>

I want to create a <<remember>> macro to keep this information available upon reloads for users or atleast a window.print() function that would allow users to print their character sheet. Any help would be appreciated.

Thanks

Comments

  • Or if there is a way to window.print() or <<remember>> just the contents of a passage that would be ideal. Users have attempted to use the save function but each time they reload their saved content it reloads the page which causes the random variables to reset causing them to loose the data on their character sheet.
  • JohnMcNabb wrote: »
    Users have attempted to use the save function but each time they reload their saved content it reloads the page which causes the random variables to reset causing them to loose the data on their character sheet.
    Set the variables in a separate passage, one that you normally do not or cannot go to—e.g. StoryInit—and they won't get reset upon loading a save. Or, only set them on demand—e.g. with <<click>>.

    Enabling the built-in seedable PRNG would also fix the issue, however, you're better off simply fixing the issue with how you're assigning random values to your stats.
  • edited August 2016
    There's probably no reason to use an array for many of these if it is causing issues. You could do it long form as in

    <<remember $dex to random(9)>>

    on the initial character sheet that's only caused once

    then

    <<print $dex>>

    on any subsequent viewings of the character sheet, differentiated using <<if visited>> macros.

    The important thing is to separate the initial creation of the variables from any subsequent viewings.
Sign In or Register to comment.