• 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 button - No action?

TCArknight

Well-known member
I have an action button on a portal.
Code:
    <portal
      id="rollability"
      style="actBig"
      tiptext="Click to roll your ability scores.">
      <action
        action="trigger"
        confirm="This will reroll your base attributes. Proceed?">
        <trigger><![CDATA[
		  perform hero.assign[Helper.RollAbilities]
		  notify "Button Clicked"
		]]></trigger>
        <buttontext><![CDATA[
          @text = "Roll Abilities"
          ]]></buttontext>
        </action>
      </portal>
When the button is clicked the confirmation message does pop up. But, the Helper.RollAbilities tag is never assigned to the hero, and the notify never shows.

Am I missing something regarding the trigger?
 
You can't assign tags permanently with a trigger script - they'll vanish once the current calculation pass is done, because tag lists are always empty at the beginning of evaluation, and then the scripts assign more tags, and the button's script isn't running every single calculation pass. The script will have to change a user field or a persistent derived field, and then a script will look at that to determine whether to assign the tag.
 
Thanks Mathias. :)

I did try having an foreach pick loop in the trigger to step through each Attribute on the hero and modify a field, but that didn’t seem to work either.

Neither did calling a procedure that did the same.

Shouldn’t the notify statement run at least? Even if it’s the only thing in the trigger, no notification pops up.
 
Does the notify pop up the next time you make some other change - just enough to trigger a re-evaluation, like adding and deleting a space from the name?



If not, test whether commenting out line 1 of that script gets the notify working - could be that assigning a tag is really bad, but not something that's getting a warning, so HL just stops running the script.
 
No such luck....
Code:
    <portal
      id="rollability"
      style="actBig"
      tiptext="Click to roll your ability scores.">
      <action
        action="trigger"
        confirm="This will reroll your base attributes. Proceed?">
        <trigger><![CDATA[
		~declare variables that are used to communicate with our caller
		var NumOfDice as number
		var SizeOfDice as number
		var total as number
		var myVal as number
	
		NumOfDice = 3
		SizeOfDice = 6
		~[B]call DieRoll[/B]
		var i as number
	
		total = 0
		for i = 1 to NumOfDice
		  total += random(SizeOfDice)
		  next
	  
		if (total <= 3) then 
		  myVal = -2
		elseif (total <= 5) then 
		  myVal = -1
		elseif (total <= 8) then 
		  myVal = 0
		elseif (total <= 11) then 
		  myVal = 1
		elseif (total <= 14) then 
		  myVal = 2
		elseif (total <= 17) then 
		  myVal = 3
		elseif (total <= 18) then 
		  myVal = 4
		  endif
			  
		hero.child[abilAccuracy].field[trtBase].value = myVal
		]]></trigger>
        <buttontext><![CDATA[
          @text = "Roll Abilities"
          ]]></buttontext>
        </action>
      </portal>

the trtBase field is defined as:
Code:
    <field
      id="trtBase"
      name="Base Value"
      type="derived"
	  persistence="full"
      defvalue="0">
      </field>

There is no change to the value in trtBase after confirming the trigger. (most of the content is in the DieRoll procedure, but as the call DieRoll didn't seem to work, I moved the rest into the trigger directly.

Thing is, I'm not seeing a difference between what I have, and the same type of portal from the sample In Play tab.
 
Ok, one thing I notice is that each other instance of the triggers are part of portals that are in templates.

I try modifying it to part of a template:
Code:
  <template
    id="baRoll"
    name="Roll Abilities"
    compset="Ability"
    marginhorz="16"
    marginvert="3">
	
    <portal
      id="rollability"
      style="actBig"
      tiptext="Click to roll your ability scores.">
      <action
        action="trigger">
        <trigger><![CDATA[
		~declare variables that are used to communicate with our caller
		var NumOfDice as number
		var SizeOfDice as number
		var total as number
		var myVal as number
		NumOfDice = 3
		SizeOfDice = 6
		call DieRoll
	  
		if (total <= 3) then 
		  myVal = -2
		elseif (total <= 5) then 
		  myVal = -1
		elseif (total <= 8) then 
		  myVal = 0
		elseif (total <= 11) then 
		  myVal = 1
		elseif (total <= 14) then 
		  myVal = 2
		elseif (total <= 17) then 
		  myVal = 3
		elseif (total <= 18) then 
		  myVal = 4
		  endif
		  
		hero.child[abilAccuracy].field[trtBase].value = myVal
		herofield[acCashCfg].value += 1000
		]]></trigger>
        <buttontext><![CDATA[
          @text = "Roll Abilities"
          ]]></buttontext>
        </action>
      </portal>
At this point, when I click the 'button' I get:
Use of a trigger script requires a valid pick context be established
and also, the buttontext doesn't show on the button....
 
For that error, please show me the <templateref/> down in the layout element where this template has been placed.
 
I had a feeling I might be missing something there, but couldn’t figure out what....
Code:
<templateref template=“baRoll” taborder=“60” />

And..... I think I see what’s missing. Would I need to add a thing=“” entry for it? If so, would it be actor or the ability component?
 
Since you have a line in there that's modifying abilAccuracy, I'd use abilAccuracy. That way, that line can be changed to:

field[trtBase].value = myVal


The actor should also work.
 
I did have to modify a couple of things, but it works. :)

Just in case anyone else wants to use it:
Code:
  <template
    id="baRoll"
    name="Roll Abilities"
    compset=[B][I]"Actor"[/I][/B]
    marginhorz="16"
    marginvert="3">
	
    <portal
      id="rollability"
      style="actBig"
      tiptext="Click to roll your ability scores.">
      <action
        action="trigger"
        confirm="This will reroll your base attributes. Proceed?">
        <trigger><![CDATA[
			call RollAbilities
		]]></trigger>
        <buttontext><![CDATA[
          @text = "Roll Abilities"
          ]]></buttontext>
        </action>
      </portal>

    <position><![CDATA[
      ~set up our height based on our tallest portal
      height = portal[rollability].height

      ~if this is a "sizing" calculation, we're done
      doneif (issizing <> 0)

      ~position our tallest portal at the top
      portal[rollability].top = 0

      ~position the rollability portal on the far right
      perform portal[rollability].alignedge[right,0]

      ]]></position>

    </template>
Code:
    <templateref template="baRoll" [B][I]thing="actor" [/I][/B]taborder="60" />
 
Back
Top