Hi,
I’m currently trying to generate some encounters. The problem I have run into is there is only 1 action statement for each button action.
So when I want to generate an en encounter the result of the first dice rolls need to be computed before the next actions can be randomized.
I tried to solve this by just generating a lot of randoms in advance, but this fails when trying to store the results.
Is there a way to solve this or do I need a two button system to generate then store the results.
Below is the current version, it first sets 16 random numbers then uses these numbers to generate mobs.
<$button actions='
<$action-setfield $tiddler="$:/temp/persistent-randomR1" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR2" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR3" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR4" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR5" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR6" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR7" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR8" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR9" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR10" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR11" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR12" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR13" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR14" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR15" text={{{ [random[1],[20]] }}}/>
<$action-setfield $tiddler="$:/temp/persistent-randomR16" text={{{ [random[1],[20]] }}}/>
' >
Roll for Encounters
</$button>
<!-- First decide the threat level of the first mob -->
<% if [[1]match{$:/temp/persistent-randomR1}] %>
Very Weak
<% elseif [[20]match{$:/temp/persistent-randomR1}] %>
Very Strong
<% elseif [[15]compare:number:lteq{$:/temp/persistent-randomR1}] %>
Strong
<% elseif [[5]compare:number:gteq{$:/temp/persistent-randomR1}] %>
Weak
<% else %>
Average
<% endif %>
<!-- First decide the type of the first mob -->
<% if [[1]match{$:/temp/persistent-randomR2}] %>
Boss
<% elseif [[20]match{$:/temp/persistent-randomR2}] %>
Elite
<% elseif [[15]compare:number:lteq{$:/temp/persistent-randomR2}] %>
Lesser
<% elseif [[5]compare:number:gteq{$:/temp/persistent-randomR2}] %>
Minion
<% else %>
Average
<% endif %>