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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
arsnik
Newbie


Joined: 28 Jun 2006
Posts: 4

PostPosted: Wed Jun 28, 2006 12:36 pm   

Using Triggers to color parts of my prompt
 
I have been using Zmudd for about 7 years and have not had to create any triggers other than adding sound effects until recently. I didn't want to post but I am having a hell of a time getting this to work.

Let me tell you what I am doing and perhaps you can assist me in fixing the error in my ways.
My prompt looks like this:
HP: 900/900 SP: 550/550 EXP: 11,323,423 DAM: 203 (shield) (blur)


I click on the Trigger icon at the top of the Zmudd window.
I click New Trigger
I select Zmudd script
In the pattern box I type this:
Code:

 HP~: (%d)/(%d)  SP~: (%d)/(%d)  EXP~: *  DAM~: *


In the script box I type this:
Code:

#TR "prompt" { HP~: (%d)/(%d)  SP~: (%d)/(%d)  EXP~: *  DAM~: *} {
#MATH hp ((%1 * 100)/%2)
#MATH sp ((%3 * 100)/%4)
#IF (@hp < 60) {#PCOL red %x1}
#IF (@sp < 60) {#PCOL "hi,blue" %x3}
} "" {prompt}


I click on the test tab.
Input the prompt line above.
The test works returning the values of %1 %2 %3 %4

However when I load my Mudd no colors change.

Please not this is based off of code writting by another:
Code:

#TR "prompt" {~< (%d)h/(%d)H (%d)v/(%d)V P:* ~>} {
#MATH myhpstats ((%1 * 100)/%2)
#MATH mymvstats ((%3 * 100)/%4)
#VAR hpcol 1
#IF (@myhpstats < 100) {#VAR hpcol 2}
#IF (@myhpstats < 90) {#VAR hpcol 3}
#IF (@myhpstats < 75) {#VAR hpcol 4}
#IF (@myhpstats < 50) {#VAR hpcol 5}
#IF (@myhpstats < 30) {#VAR hpcol 6}
#IF (@myhpstats < 15) {#VAR hpcol 7}
#VAR mvcol 1
#IF (@mymvstats < 65) {#VAR mvcol 2}
#IF (@mymvstats < 30) {#VAR mvcol 3}
#PCOL %case( @hpcol, green, brown, yellow, "hi,magenta", magenta, "hi,red", red) %x1
#PCOL green %x2
#PCOL %case( @mvcol, blue, "hi,blue", cyan) %x3
#PCOL blue %x4
} "" {prompt}


Which I have also tried with no luck (changing the pattern to match the one I am using). I keep getting syntax errors with
Code:
 #PCOL blue %x4


Note:
I have also tried entering this from the command line. Which doesn't work at all.

Any help would be wonderful. In the mean time I will continue my research.

BTW I have seen in many cases were
Code:
 { HP~: (%d)/(%d)  SP~: (%d)/(%d)  EXP~: *  DAM~: *}
was also written as
Code:
 { HP~: (%d)~/(%d)  SP~: (%d)~/(%d)  EXP~: *  DAM~: *} 

Which format is correct?

Help, plz
Thanks in adance
Reply with quote
arsnik
Newbie


Joined: 28 Jun 2006
Posts: 4

PostPosted: Wed Jun 28, 2006 12:39 pm   
 
Zmudd version 7.21 Public
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Wed Jun 28, 2006 6:26 pm   
 
Code:
#TRIGGER "prompt" {HP: (%d)/(%d) SP: (%d)/(%d) EXP: * DAM: *} {#MATH hp ((%1 * 100)/%2);#MATH sp ((%3 * 100)/%4);#IF (@hp < 60) {#PCOL red %x1};#IF (@sp < 60) {#PCOL "hi,blue" %x3}} "" {prompt}


This worked for me, using your example.

I'm not sure why, but the trigger pattern you posted didn't match the example prompt line when I first entered it in zMUD. I ended up recreating the pattern in the settings editor and started getting the expected results.

The quote char (~ by default) just tells zMUD to match the character following it, as it appears (verbatim).

Because special characters allow users to manipulate patterns, zMUD will manipulate patterns if those special characters are present and not quoted.

As you can see above, this trigger works without quoting the colons or the slashes.

Some characters that USUALLY NEED to be quoted in trigger patterns are: ~<>(){}[]
Reply with quote
BlackSmith
Apprentice


Joined: 08 Dec 2002
Posts: 152

PostPosted: Thu Jun 29, 2006 9:14 am   
 
Forget the whole ~issue and use PERL regex. You dont have to wonder if someone uses the ~ for something else in his settings or anything crappy like that.
Code:
 HP: (\d+)/(\d+)  SP: (\d+)/(\d+)  EXP: .*  DAM: .*
copy paste that to pattern and [x] Perl regural experssion
_________________
BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient.
Reply with quote
arsnik
Newbie


Joined: 28 Jun 2006
Posts: 4

PostPosted: Thu Jun 29, 2006 4:53 pm   
 
I have one other question when creating a trigger.

In the pattern field I type in the pattern.

Why do I need to declare the pattern a 2nd time in the line script?
Code:

#TRIGGER "prompt" {HP: (%d)/(%d) SP: (%d)/(%d) EXP: * DAM: *}


In addition when I use the #PLAY to play sounds I only have to type in the pattern and the #PLAY ... I don't even need to declare #TR

I am a little confuse on all this works.

It would probably be so much easier if there wasn't so much GUI involved. (maybe)

I read the the documentation but the one tab that I need info on is not documented that os the pattern tab.
Reply with quote
BlackSmith
Apprentice


Joined: 08 Dec 2002
Posts: 152

PostPosted: Tue Jul 04, 2006 1:25 pm   
 
arsnik wrote:
Why do I need to declare the pattern a 2nd time in the line script?
Umm... You dont.
Look at this. This is how your trigger should look like.

arsnik wrote:
It would probably be so much easier if there wasn't so much GUI involved. (maybe).
If there would be less GUI then you would be doing those triggers and handling them trough a interface that looks lot like DOS prompt.
_________________
BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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