Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
ianreecej
Newbie


Joined: 19 Feb 2013
Posts: 3

PostPosted: Tue Feb 19, 2013 4:37 am   

Cmud trigger/variable assistance
 
Okay so I don't know why but I can not for the life of me get a simple trigger to capture the mud's hp output and put that in a button.
The output by the mud looks like so [HP: 100%] [ME:100%] [PE:100%]

Could someone please provide a solution or guide me to grabbing these values.

Currently this is what I have.

<class name="Gauge" id="719">
<var name="HpVar" id="720">98</var>
<var name="MeVar" id="721">98</var>
<var name="PeVar" id="722">100</var>
<button type="Gauge" variable="HpVar" autosize="false" width="60" height="23" color="red" gaugelowcol="red" gaugebackcol="#F0F0F0" priority="260" id="723">
<caption>Health</caption>
</button>
<button type="Gauge" variable="MeVar" autosize="false" width="60" height="23" color="#33CCCC" gaugelowcol="red" gaugebackcol="#F0F0F0" priority="270" id="724">
<caption>Mana</caption>
</button>
<button type="Gauge" variable="PeVar" autosize="false" width="60" height="23" color="#FFCC00" gaugelowcol="red" gaugebackcol="#F0F0F0" priority="280" id="725">
<caption>Physical</caption>
</button>
</class>
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Feb 19, 2013 7:54 pm   
 
You are probably just forgetting to precede the square brackets and percent sign with the quote mark: ~. Some characters have a special meaning in a trigger, so to match those characters you have to quote them. Try this trigger:
Code:

<trigger priority="10" prompt="true" id="1">
  <pattern>~[HP:{%s|}(%d)~%~] ~[ME:{%s|}(%d)~%~] ~[PE:{%s|}(%d)~%~]</pattern>
  <value>#VAR HpVar %1
#VAR MeVar %2
#VAR PeVar %3
</value>
</trigger>

By the way, the example prompt you provided is inconsistent. Is there supposed to be a space after the : or not? You have it both ways in that example. But the pattern in the trigger I've provided will work whether or not there is a space, and whether or not there is a newline after the prompt.
Reply with quote
ianreecej
Newbie


Joined: 19 Feb 2013
Posts: 3

PostPosted: Tue Feb 19, 2013 8:27 pm   
 
The answer to your question is both yes and no. If the value is 100 there is no space is it is less than 100 there is a space. So how would I go About handling that?

This is a direct paste from the MUD.

[HP:100%] [ME: 47%] [PE:100%]

Here is the issue now. Your trigger works but only is all three are under 100%. If any of the three are at 100 it stops grabbing the value due to a non matching pattern.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Feb 19, 2013 8:55 pm   
 
Are you sure? That trigger should match both with and without a space, as Rahab said. I just tested his pattern with your last direct paste and it matched for me.
Reply with quote
ianreecej
Newbie


Joined: 19 Feb 2013
Posts: 3

PostPosted: Tue Feb 19, 2013 8:59 pm   
 
Scratch that I solved it. It's not pretty but I make 6 separate triggers for each instance so one with a space and one without for each HP, ME and PE. Is there a better cleaner way? Just curiosity at this point.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Feb 19, 2013 9:00 pm   
 
Yes, the better cleaner way is what Rahab posted.

EDIT: Here's something you can try: open the package editor, find the trigger, and go to the pattern tab. Copy in the text from the mud into the box there. If it says it doesn't match, there's another problem, so paste that text that doesn't match here please. As I said, I did this with the sample text you provided, and Rahab's pattern matched.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Feb 20, 2013 1:06 am   
 
My trigger should work whether they had spaces or not. If you have a prompt for which my trigger does not work, please post it so we can see what the difference is.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net