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
rto0288
Beginner


Joined: 23 Apr 2006
Posts: 11

PostPosted: Mon Apr 24, 2006 12:24 am   

Serious issue with enemy highlighting script
 
I have a class called enemies in which I have:
- stringlist variable @enemylist to hold list of enemies
- variable @enemyblink to set whether or not enemy names blink (0 or 1)
- variable @enemycolor (color enemy names are highlighted)

okay then I have this regex trigger: \b(@enemylist+)\b
with a value of:
#if {@enemy_blink=0} {
#SUB {
~<color @enemy_color>
~<b>
~<send "t %1">%1~</send>
~<b>
~</color>
}
} {
#SUB {
%ansi(blink)~<color @enemy_color>
~<b>
~<send "t %1" "target %1">
%1
~</send>
~<b>
~</color>
}
} {
#SUB {
~<color @enemy_color>
~<b>
%1
~<b>
~</color>
}
}
-------It doesn't LOOK like this, I intdented it for eas of reading----------

This works fine for any single name on my @enemylist. I usually keep enemyblink off (0) but I've tested it and it works. The problem I'm having occurs when there's multiple enemy names in the same line so:
"<enemy1> enters the room" is fine but "<enemy1> says, '<enemy2> sucks'" comes up all screwed up. Basically what happens is the #IF is ignored the second time around so <enemy1> comes up highlighted but <enemy2> is displayed 3 times, once not blinking and twice blinking (with all the ELSE code visible on screen including {'s. and it's ALL BLINKING. Heh this isn't a great thing as I'm sure you can imagine, any ideas?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Apr 24, 2006 2:12 am   
 
Quote:

{
#SUB {
%ansi(blink)~<color @enemy_color>
~<b>
~<send "t %1" "target %1">
%1
~</send>
~<b>
~</color>
}
} {
#SUB {
~<color @enemy_color>
~<b>
%1
~<b>
~</color>
}
}



Your problem is that you have an extra code block of #SUB and various MXP commands, and it's contained within the false-condition codeblock of the #IF command.
_________________
EDIT: I didn't like my old signature
Reply with quote
rto0288
Beginner


Joined: 23 Apr 2006
Posts: 11

PostPosted: Mon Apr 24, 2006 6:41 am   kinda helped but...
 
okay eliminated some of the mess but the original problem remains. if I have two enemies: talgon and rukimoro, I can say talgon and his name will be highlighted in red (not blinking because I don't use that much). Same goes for if I were to say Rukimoro. All's fine. now if I say: "talgon rukimoro" this is what will show up:

You say, "Talgon {1=0} {#SUB {rukimoro}} {#SUB {rukimoro}}."

rather than: You say, "Talgon rukimoro"

I'm completely stumped. Thanks so much for responding to my original post, I hope you can provide some further insight into this situation.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Apr 24, 2006 10:47 pm   
 
Oh, I missed that one. The #IF command requires that you use parentheses instead of curly brackets for the condition to be evaluated:

#IF (condition) {true} {false}

That will get rid of the visible code. I don't know if Regex patterns work any differently, but ZMud wildcard pattern triggers are only executed once per line so you aren't going to be able to also get rukimoro highlighted. If it turns out that regex patterns are the same way then you need to look into the reparse condition or go with separate triggers.
_________________
EDIT: I didn't like my old signature
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon Apr 24, 2006 11:56 pm   
 
When I highlight enemy names, I don't need + in the pattern, either. The regex trigger pattern "\b(@enemylist)\b" seems to work repeatedly on the same line, where the standard zMUD pattern does not. I don't know if this helps you or not, but just thought I'd mention it.
Reply with quote
rto0288
Beginner


Joined: 23 Apr 2006
Posts: 11

PostPosted: Tue Apr 25, 2006 4:29 am   
 
hmm, that didn't work either but I managed to fix the problem by creating two separate triggers with different IDs (one for blinking and one for not) and having only one or the other active, toggling them with the enemyblink alias. Using regex does allow the trigger to execute multiple times per line, and, you're correct Larkin, the '+' was unnecessary. I'm pleased to have this working now but the original issue is still bugging me so I'd love to pursue this further if anyone feels like it. Even after removing that unnecessary block of code and changing the {} to () I still see code if two or more enemy names are present on the same line except now it's (using the previous example):

You say, "Talgon (1=0) {#SUB {rukimoro}} {#SUB {rukimoro}}."

*shrug* I don't get it, it LOOKS like it should work fine. Thanks a lot for all your help though Matt, any further insight would be appreciated.
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