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
forren
Novice


Joined: 26 Apr 2007
Posts: 44

PostPosted: Thu Apr 26, 2007 6:06 pm   

[1.30] Local variable trigger assignment
 
So, here's what I made:

Pattern:

^(&currentHealth)h, (&currentMana)m, (&currentEgo)e, (&currentPower)p, (&currentEndurance)en, (&currentWillpower)w ($promptCharacters:%w)-$

Some curious issues with this pattern. #SHOW $promptCharacters shows what is currently in &currentPower. I isolated them by using traditional %1, %2 characters, and it turns out that each of these seems to have created two %xs - %1 and %2 both refer to the number in &currentHealth, %3 and %4 refer to the number in &currentMana, etc. %7 should be what $promptCharacters is. Instead, $promptCharacters is %13!

Am I doing something wrong, or is this a bug?
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Apr 26, 2007 6:17 pm   
 
As I said on the Lusternia forums, you're missing wildcards in your first six matches. It may still be uncovering parsing problems in CMUD (should probably throw a scripting exception, unless there is a default wildcard of which I'm unaware). Try adding the %d to your first six pattern matches and see if it makes a difference.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Apr 26, 2007 6:35 pm   
 
CMUD doesn't currently allow mixing of both the &varname and ($local:pattern) syntax in the same trigger. So yes, it's going to get confused. When you don't specify a wildcard, CMUD defaults to using * for the wildcard, so I don't think the missing patterns will matter.

I've added this to the bug list.
Reply with quote
forren
Novice


Joined: 26 Apr 2007
Posts: 44

PostPosted: Thu Apr 26, 2007 6:37 pm   
 
This should not be necessary according to the #HELP:

Code:
However, there is an even easier way to do this using the &VarName syntax in the trigger patter:

#TRIGGER {Hp: &HpVar Mana: &ManaVar}

No action is needed...the captured values are automatically stored into the specified variables if the pattern matches.

By default, the &VarName syntax uses a wildcard pattern of * to match the text. To change the wildcard that is used, specify it just after the & character. Or, if you want to use the square brackets [] to define your own wildcard range, put it after the & character. For example, to only capture the digits 0,1,2 into a variable, you would do:


All of these values are getting stored correctly. The only issue is with the local variable.
Reply with quote
forren
Novice


Joined: 26 Apr 2007
Posts: 44

PostPosted: Thu Apr 26, 2007 6:38 pm   
 
Zugg wrote:
CMUD doesn't currently allow mixing of both the &varname and ($local:pattern) syntax in the same trigger. So yes, it's going to get confused. When you don't specify a wildcard, CMUD defaults to using * for the wildcard, so I don't think the missing patterns will matter.

I've added this to the bug list.


Ah, thanks.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Apr 26, 2007 7:14 pm   
 
I admit I was too lazy to check the help file, but I suspected it would assume * if no wildcard was provided. Still, using %d would be a good idea, on the wildly off chance that you'd match something else you didn't want.

I'm still sticking with no variable names in trigger patterns for now, assigning them to local or non-local variables inside the trigger code as necessary.
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