• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Trigger random value

Gomo

Well-known member
I've made some test to implement dice to my Tactical Console (unfortunately Dice roller works with successes above given value instead of equal and below, which I need) with result giving me random numbers, but each time I am making some changes.
So I try to make a trigger which will perform this task, but right now it doesn't work.
My prototype:
Code:
<portal
      id="attack"
      style="actReroll"
      tiptext="Atak">
      <action
        action="trigger">
        <trigger><![CDATA[
		var temp as number
		temp = random(10) + 1
		                    ~herofield[acAbandon].value = 1
          perform herofield[acDie].value = 0
		  ~ perform field[trkUser].reset

          ]]></trigger>
        </action>
      </portal>

With acDie defined in Actor:
Code:
 <field
      id="acDie"
      name="Die"
      type="user"
	  defvalue="0">
	  </field>

And I've got such error:
Code:
Syntax error in 'trigger' script for Template 'tacPick' (in Portal 'attack') on line 5
  -> Error in string expression

Is it possible to make it work? I didn't found much about implementation of random on the forum or the wiki.
 
The error you're getting is not related to using a random number. It's this line that's the problem:

Code:
perform herofield[acDie].value = 0

Study that code, and compare it to other code you've seen - why is that not the right code to set the value of a field?
 
OK, I've made some changes and managed to make it work.
I've added an usagepool like this:
Code:
<usagepool
    id="Die"
    name="Die"
    abbrev="Die"
    ishero="yes"
    persist="yes"/>
a portal to track the value:
Code:
	  	  	      <portal
      id="gain"
      style="lblSmlLeft">
      <label
        ismultiline="yes">
        <labeltext><![CDATA[
		  @text = "{size 30}Gain: {size 36}" & hero.usagepool[Die].value
          ]]></labeltext>
        </label>
and modified existing trigger:
Code:
	      <portal
      id="attack"
      style="actReroll"
      tiptext="Atak">
      <action
        action="trigger">
        <trigger><![CDATA[
		var temp as number
		temp = random(10) + 1
		  perform hero.usagepool[Die].empty
		  perform hero.usagepool[Die].adjust[temp]
          perform hero.usagepool[Die].set[temp]
          ]]></trigger>
        </action>
      </portal>
 
Back
Top