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
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 7:34 pm   

[2.33] Bug? Triggers sometimes not being created in the right classes
 
Sometimes when I run an alias, it randomly will not create a trigger in the proper class, and instead doesn't put it in a class at all. The trigger it creates outside the class seems random; sometimes it is one trigger and not another, and the next time it will be a completely different trigger, next time it might be two triggers instead of one, etc. Sometimes it does run properly and puts the triggers in the right classes, but it's not reliable.

This alias, for example, is within the class it tries to create the triggers in, in case it matters. (universal/generic_scripts/vocals)

Code:
#EXECUTE {queue stop hum}

#IF (%1=="") {
// Handles playing at the correct difficulty.
#VAR ./universal/generic_scripts/vocals/vocset 0

#TRIGGER {^You begin to hum %w %w %w.} {#ADD vocdiff 1} vocals
#TRIGGER {your heart swelling in pride at your hard-earned skill.$} {#ADD vocdiff 1} vocals
#TRIGGER {your skill in your craft} {#ADD vocdiff 1} vocals
#TRIGGER {^You*with only the slightest hint of difficulty.$} {#ADD vocdiff 1} vocals
#TRIGGER {^You fumble slightly as you begin} {#ADD vocdiff -1;#ADD vocset 1} vocals
#TRIGGER {^You struggle to begin} {#ADD vocdiff -1} vocals

#IF (@vocdiff<1) {#VAR vocdiff 1}

#WHILE (@vocset==0) {
#IF (@vocdiff==1) {#VAR vocplay scales}
#IF (@vocdiff==2) {#VAR vocplay arpeggio}
#IF (@vocdiff==3) {#VAR vocplay ditty}
#IF (@vocdiff==4) {#VAR vocplay folk}
#IF (@vocdiff==5) {#VAR vocplay ballad}
#IF (@vocdiff==6) {#VAR vocplay waltz}
#IF (@vocdiff==7) {#VAR vocplay lullaby}
#IF (@vocdiff==8) {#VAR vocplay march}
#IF (@vocdiff==9) {#VAR vocplay jig}
#IF (@vocdiff==10) {#VAR vocplay lament}
#IF (@vocdiff==11) {#VAR vocplay wedding}
#IF (@vocdiff==12) {#VAR vocplay hymn}
#IF (@vocdiff==13) {#VAR vocplay rumba}
#IF (@vocdiff==14) {#VAR vocplay polka}
#IF (@vocdiff==15) {#VAR vocplay battle}
#IF (@vocdiff==16) {#VAR vocplay reel}
#IF (@vocdiff==17) {#VAR vocplay elegy}
#IF (@vocdiff==18) {#VAR vocplay serenade}
#IF (@vocdiff==19) {#VAR vocplay minuet}
#IF (@vocdiff==20) {#VAR vocplay psalm}
#IF (@vocdiff==21) {#VAR vocplay dirge}
#IF (@vocdiff==22) {#VAR vocplay gavotte}
#IF (@vocdiff==23) {#VAR vocplay tango}
#IF (@vocdiff==24) {#VAR vocplay tarantella}
#IF (@vocdiff==25) {#VAR vocplay bolero}
#IF (@vocdiff==26) {#VAR vocplay nocturne}
#IF (@vocdiff==27) {#VAR vocplay requiem}
#IF (@vocdiff==28) {#VAR vocplay fantasia}
#IF (@vocdiff==29) {#VAR vocplay rondo}
#IF (@vocdiff==30) {#VAR vocplay aria}
#IF (@vocdiff==31) {#VAR vocplay sonata}
#IF (@vocdiff==32) {#VAR vocplay concerto}

#EXECUTE {queue hum @vocplay}
#WAITFOR {^You *hum*$}
#EXECUTE {queue stop play}
#WAITFOR {^You stop playing your song.$}
#WAIT 1000
}

#IF (@vocdiff==1) {#VAR vocplay scales}
#IF (@vocdiff==2) {#VAR vocplay arpeggio}
#IF (@vocdiff==3) {#VAR vocplay ditty}
#IF (@vocdiff==4) {#VAR vocplay folk}
#IF (@vocdiff==5) {#VAR vocplay ballad}
#IF (@vocdiff==6) {#VAR vocplay waltz}
#IF (@vocdiff==7) {#VAR vocplay lullaby}
#IF (@vocdiff==8) {#VAR vocplay march}
#IF (@vocdiff==9) {#VAR vocplay jig}
#IF (@vocdiff==10) {#VAR vocplay lament}
#IF (@vocdiff==11) {#VAR vocplay wedding}
#IF (@vocdiff==12) {#VAR vocplay hymn}
#IF (@vocdiff==13) {#VAR vocplay rumba}
#IF (@vocdiff==14) {#VAR vocplay polka}
#IF (@vocdiff==15) {#VAR vocplay battle}
#IF (@vocdiff==16) {#VAR vocplay reel}
#IF (@vocdiff==17) {#VAR vocplay elegy}
#IF (@vocdiff==18) {#VAR vocplay serenade}
#IF (@vocdiff==19) {#VAR vocplay minuet}
#IF (@vocdiff==20) {#VAR vocplay psalm}
#IF (@vocdiff==21) {#VAR vocplay dirge}
#IF (@vocdiff==22) {#VAR vocplay gavotte}
#IF (@vocdiff==23) {#VAR vocplay tango}
#IF (@vocdiff==24) {#VAR vocplay tarantella}
#IF (@vocdiff==25) {#VAR vocplay bolero}
#IF (@vocdiff==26) {#VAR vocplay nocturne}
#IF (@vocdiff==27) {#VAR vocplay requiem}
#IF (@vocdiff==28) {#VAR vocplay fantasia}
#IF (@vocdiff==29) {#VAR vocplay rondo}
#IF (@vocdiff==30) {#VAR vocplay aria}
#IF (@vocdiff==31) {#VAR vocplay sonata}
#IF (@vocdiff==32) {#VAR vocplay concerto}

#UNTRIGGER {^You begin to hum %w %w %w.} vocals
#UNTRIGGER {your heart swelling in pride at your hard-earned skill.$} vocals
#UNTRIGGER {your skill in your craft} vocals
#UNTRIGGER {^You*with only the slightest hint of difficulty.$} vocals
#UNTRIGGER {^You fumble slightly as you begin} vocals
#UNTRIGGER {^You struggle to begin} vocals
#UNVAR ./universal/generic_scripts/vocals/vocset

//Hums until mind locked, then waits a pulse and hums if not mind locked.

#TRIGGER {Vocals:%s%d %d.%d~% mind lock} {#WAIT 200000;#EXECUTE {queue exp skill vocals}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% dazed} {#WAIT 200000;#EXECUTE {queue exp skill vocals}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% clear} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% learning} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% thoughtful} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% pondering} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% concentrating} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% muddled} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% very} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% perplex} {#EXECUTE {queue hum @vocplay}} vocals
#TRIGGER {Vocals:%s%d %d.%d~% bewilder} {#EXECUTE {queue hum @vocplay}} vocals

#TRIGGER {^You finish humming} {#EXECUTE {queue exp skill vocals}} vocals

#EXECUTE {queue exp skill vocals}} {

#UNTRIGGER {Vocals:%s%d %d.%d~% mind lock} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% dazed} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% clear} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% learning} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% thoughtful} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% pondering} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% concentrating} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% muddled} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% very} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% perplex} vocals
#UNTRIGGER {Vocals:%s%d %d.%d~% bewilder} vocals

#UNTRIGGER {^You finish humming} vocals
}


So, for example, the last several times I ran it, it ran fine most of the time, and then one time #TRIGGER {Vocals:%s%d %d.%d~% thoughtful} {#EXECUTE {queue hum @vocplay}} vocals was just hanging out outside the classes, and another time it was #TRIGGER {Vocals:%s%d %d.%d~% pondering} {#EXECUTE {queue hum @vocplay}} vocals instead. I just ran it again and this time it was #TRIGGER {Vocals:%s%d %d.%d~% learning} {#EXECUTE {queue hum @vocplay}} vocals.

It seems to be a bug with classes in general and not just this particular alias, too, since I've gotten it to happen with other aliases as well. In general it seems like I've had a lot of buggy things going on since I started to organize things into classes, stuff that worked fine before. :-/ I'll copy and paste the others when it happens.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jul 26, 2008 8:11 pm   
 
Nattie have you considered using a database variable for your song types?

If you do, then instead of 32 #if statements you could just make it this:

Code:
#IF (@vocset==0) {vocplay=%db(@voctype,@vocdiff)}


The keys for voctype would be the numbers 1-32 and the corresponding values would be the types like ballad, folk, or whatever. Since those values don't change right? It would save you from typing 64 #if statements. Also not sure why you are using a #while loop when all you need is an #if statement.
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 8:20 pm   
 
The database is a good idea, thank you!

I need the while loop because it goes through and tests each time. If I don't hum it with the "slightest hint of difficulty" it means I need to try something harder or easier, depending on the messaging it gets back. So it goes through and tests until it finds the hardest "slightest hint of difficulty" hum I can do. Once it hits the one I fumble on, it stops the loop, subtracts one from the difficulty so I go back to the one before it (the hardest one I want to do) and then it needs the second set of #IFs to realign the difficulty with the appropriate word.

But still, the classes thing is buggy. The script itself works fine, does exactly what I want even without the database and everything. It always works. It just randomly doesn't create the trigger in an appropriate class. :-/
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jul 26, 2008 10:05 pm   
 
Okay. Regardless, using the database would make your life a lot easier.

Another thing I am wondering is why you are creating and destroying triggers? Have you thought about just enabling and disabling them? It would also be a big improvement.
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 10:38 pm   
 
Well, haha, the answer to that is because I only learned about how to enable/disable them the day before yesterday. ^^; I just started using CMUD about a week ago, so I've kept running back to the manual to figure out what to do... #UNTRIGGER stood out, but #T- didn't. I went through and read all the command things one by one the other day, so that was enlightening. I'm trying to do the same with the functions and such as well, so I know what's available to me. So I should probably go through and change the untriggers to #T-s.

Just to be sure, though... I have a few scripts where I have the trigger pattern do one thing, then delete it and create and new one with the same pattern that does something different. Basically, depending on when something happens, I don't want it to do the first thing and instead want it to do the second thing, and vice versa. If I give the triggers names, and then #T- them by name, that should work, right? It won't think I'm trying to disable and enable a class, or it won't try to create a class with the trigger's name to disable? Or in that circumstance, do I need to actually #TRIGGER and #UNTRIGGER?

Thanks a bunch for your help, I feel like I've learned a lot from you today. :-)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jul 26, 2008 11:00 pm   
 
Quote:
I have a few scripts where I have the trigger pattern do one thing, then delete it and create and new one with the same pattern that does something different.


In that case why not set a condition to evaluate and then execute actions based upon the answer instead of creating and destroying the same trigger.

Quote:
If I give the triggers names, and then #T- them by name, that should work, right? It won't think I'm trying to disable and enable a class, or it won't try to create a class with the trigger's name to disable?


Yes that will work fine, unless you name a trigger something that already uses that name.
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 11:02 pm   
 
Thank you! :-) I'm going to try out both of those things; I need to look at the script again to be sure I can make them conditional properly, but I think I probably can.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jul 26, 2008 11:30 pm   
 
An even EASIER way to handle those triggers would be to place all of them in a subclass of Vocals class. So lets say you call the class folder VocalTrigs or whatever.

Then all you would have to do to disable them would be:

#TRIGGER {^You finish humming} {#T- VocalTrigs}

and to enable them:

#TRIGGER {^You start to hum} {#T+ VocalTrigs}

That's probably not the trigger line you use but you get the point.

Edit: Just make sure the trigger or alias to turn that class folder on isn't inside the class folder. :-P
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Jul 27, 2008 3:21 pm   
 
Creating and destroying settings is quite slow. Turning them of and on is very fast, as is setting a variable (especially if the variable uses a default value) for use with #IF within the triggers. It is definitely better for you to learn to control your scripts with #T+, #T-, and #IFs.

It is possible there is a bug in creating and deleteing triggers, but I couldn't find it while playing with your scripts.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Mon Jul 28, 2008 5:32 pm   
 
Okay, I finally got a chance to mess with CMUD some more today, and now I'm just having a problem where #T- doesn't always disable triggers inside a class. :(

Here are my #T+s and #T-s:

Code:
#T+ {Mechanical Lore:%s%d %d.%d~% mind lock} ranger
#T+ {Mechanical Lore:%s%d %d.%d~% dazed} ranger
#T+ {^You manage to find} ranger
#T+ {^You need to have more material in your other hand to continue braiding.$} ranger

#T- {Mechanical Lore:%s%d %d.%d~% mind lock} ranger
#T- {Mechanical Lore:%s%d %d.%d~% dazed} ranger
#T- {^You manage to find} ranger
#T- {^You need to have more material in your other hand to continue braiding.$} ranger


The two triggers that start with "Mechanical Lore" are never disabled properly. If I disable them manually by right-clicking and selecting disable, the #T+ will not enable them. Neither a #T+ or #T- on these triggers will work even if I do it from the command line. The last two triggers enable and disable fine.

I'm really confused as to what I'm doing wrong, since other people don't seem to have this problem, and they don't have their triggers get created in weird folders either. What could make something like that happen? Am I completely misunderstanding how classes should work? I feel like whatever I do to get around one problem, I just run into the same sort of thing. #TRIGGER and #UNTRIGGER are wonky, so I #T+ and #T- and get similar problems. :(

If I name those two triggers, #T+ and #T- work fine all of the sudden. I really don't want to have to name every trigger I create, though; I have too many that would end up with too-similar names if their names were at all helpful, or otherwise I would have to name them sequentially with names that would be completely unhelpful to me. I really would rather enable and disable the patterns alone.

The only thing I've noticed is that often my triggers that contain %s%d %d.%d~% are the ones this happens to -- I'm not 100% certain, but if I notice it happen to another trigger I'll retract that. Is there something weird about that pattern string that's making this happen?
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Jul 28, 2008 6:49 pm   
 
It is because of the ~ character in your pattern. The #TRIGGER command parses the trigger pattern a bit differently from the #T+/- commands (because they are designed to use *names* instead of patterns). When you put a ~ in a trigger pattern, it is passed verbatim to the #TRIGGER command (as you can see if you view your trigger pattern in the settings editor).

But in the #T+/- commands (and other commands that accept a string name in addition to a pattern), the ~ character is absorbed by the command, preventing the next character in the string from being parsed. So if you want a literal ~ in your string, you need to use ~~. So, in your example above, the correct command would be:

#T- {Mechanical Lore:%s%d %d.%d~~% mind lock} ranger

This is just something you'll need to remember if you are using patterns that contain ~ and refuse to use names. Also, any trigger that has a pattern longer than 64 characters or so probably also won't work unless you use a name. This is because the database index that is used to "lookup" a trigger by the pattern is limited to 64 characters in length. So if you have 2 triggers that have the first 64 characters the same, CMUD won't be able to distinguish between them and you'll need to give them names to access them via #T+/-.
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Mon Jul 28, 2008 7:41 pm   
 
I'm a bit confused... I put the ~ there not because there is actually a tilde in the pattern, but because I'm trying to escape the %. Do I not need to escape the % character?

In case I'm not being clear, this is the kind of text from the game that I'm trying to trigger off of:
Mechanical Lore: 29 28.91% mind lock

Thank you for the information about the 64 characters!
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Jul 28, 2008 9:42 pm   
 
You need the ~% in the trigger pattern because % is normally a wildcard character in patterns (like the %w wildcard). So the ~ character "escapes" the character after it, telling the trigger pattern that it should match the % character from the MUD instead of using it as a wildcard.

When you are using #T+/#T- (and any other command that takes a *string* value for the name of a trigger), you need to create a string that exactly matches your trigger pattern. When using a string value, the ~ escapes the character after it. So if you just do this:

#T- {Mechanical Lore:%s%d %d.%d~% mind lock} ranger

then you are telling CMUD to look for the trigger with the pattern of:

Mechanical Lore:%s%d %d.%d% mind lock

But that doesn't match your trigger pattern. Your trigger pattern has the ~ in it before the % character. So, you need to use:

#T- {Mechanical Lore:%s%d %d.%d~~% mind lock} ranger

which tells CMUD to look for the trigger with a pattern of:

#T- {Mechanical Lore:%s%d %d.%d~% mind lock} ranger

Another way to think about this...the commands that take a STRING value for the trigger name (#T+/-,#UNTRIG, etc) execute the ~ character immediately. Whereas the #TRIGGER command doesn't execute the ~ until it matches the line of text from the MUD against the trigger pattern.
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Mon Jul 28, 2008 9:44 pm   
 
Ohhh, thank you! I get it now. :-)

To keep things simple I just went ahead and named my triggers that have an escape character in them, because they're always that type of trigger and the names are easy for me to remember. Things have been working much better since I named anything with a ~ or longer than 64 characters. Strange little errors no longer pop up. Thank you so much!
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