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

Joined: 12 Jan 2007
Posts: 3

PostPosted: Fri Jan 12, 2007 4:53 am   

Trigger From a Database
I have searched through the forums and can't seem to find anything like what I am trying to accomplish.

In the mud I play, there are many hidden doors. Each hidden door will have a hint/description if you look in its direction. For instance, You see a small pile of rubble here. That door might be called 'rubble'.

I would like to maintain a database of descriptions and door names, simple two column database, called hiddendoors or something.

You see a small pile of rubble here.|rubble
The way to your west seems to be blocked.|rockdoor

Then, when I look in a direction, a trigger would "fire" that would search through the database, find the matching record (dbase description column), set a variable called "targetdoor" to the appropriate door name (dbase door column), and then echo the @targetdoor to my screen.

I have been close to making this work but I often get a looping trigger situation.

Any help with this trigger would be greatly appreciated. :)
Reply with quote

Joined: 10 Dec 2006
Posts: 15

PostPosted: Fri Jan 12, 2007 3:07 pm   
You suggest that you get a looping trigger situation. You haven't specified details but the most obvious interpretation I can see of what you mean by that is that
sometimes the output of the trigger matches the trigger so causes it to be fired again forever. If this is the case, disable the 'trigger on trigger' option.

If you show us what you have 'almost working' we could give you a tip or two. The log of the typical look command would also help.

Do you have a map of your world? I handle my doors by putting them in the mud map then have custom macros and commands that open and shut them on a keypress.
Reply with quote

Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Jan 12, 2007 5:10 pm   
#ADDKEY DoorInfo {You see a small pile of rubble here.=rubble|The way to your west seems to be blocked.=rockdoor}
#TRIGGER {^({@DoorInfo})$} {TargetDoor=%db(@DoorInfo,%1);#ECHO Door is named @TargetDoor}

Short and sweet, you can use a record variable for the trigger pattern and it will match whenever one of the keys match.
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote

Joined: 12 Jan 2007
Posts: 3

PostPosted: Fri Jan 12, 2007 7:44 pm   
Thank you for the help Vijilante, however, this does not seem to work for me.

Here is what I am doing. Let's assume the databse is already filled with 125 different descriptions|doors and is called hiddendoors. The trigger is within a class called hiddendoorsb.

I have a trigger that looks like this ...

#TRIGGER {(*)} {#dbget {%find("%params")};#var targetdoor %rec.door;#class hiddendoorsb 0;dor}

I also have ...

#ALIAS {dor} {#echo --- --- --- --- @targetdoor --- --- --- ---;#color orange}

#ALIAS {do} {#var targetdoor %1;#echo --- --- --- --- @targetdoor --- --- --- ---;#color orange}

#Alias {hidn} {#class hiddendoorsb 1;#dbload hiddendoors
;look north}

I also have aliases hids, hide, hidw, hidu and hidd for other directions.

Here is how I am using this 'system' so far. If I type do rockdoor, my targetdoor is set to rockdoor and is echoed onto my screen.

In zmud I could type do without an arguement and it would show me the stored variable. In cmud it instead stores a blank space. So I have built dor, which just shows me the stored variable. (ugly workaround I know)

When I type hidn ... my targetdoor is set by first enabling the triggerclass, then the trigger fires based upon the description seen after the look north command.

I then have to force the trigger to turn off or what i get is ... it keeps setting my targetdoor back to the door name of the current database record ... even if I manually change it back to soemthing else using my do alias.

This seems to happen on the next line of text to the mud, no matter what the text is. I suspect the trigger is somehow firing all the time but am not sure.

I get the looping situation if I add this to the trigger ...

#echo @targetdoor

that command somehow loops the trigger ... I suspect that the trigger is somehow searching the database for the doorname over and over but am not positive.

Well ... any suggestions on cleaning this mess up would again be appreciated. I'd like to leave the trigger on at times when speed of play isn't as important (exploring vs. fighting other players). I can't do that now since the trigger keeps setting my targetdoor variable to the door of the current database record.
Reply with quote
Fang Xianfu

Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Jan 12, 2007 8:25 pm   
The way to fix "do" is to change it to one of the following:

#alias do {#if (%numparam()>0) {#var targetdoor %1};#echo --- --- --- --- @targetdoor --- --- --- ---;#color orange}
#alias do {#if (%numparam()=0) {#var targetdoor} {#var targetdoor %1};#echo --- --- --- --- @targetdoor --- --- --- ---;#color orange}

The rest I can't help you with, I'm afraid.

EDIT: Though I can also add that #echo will set off triggers if the output matches them.
Reply with quote

Joined: 12 Jan 2007
Posts: 3

PostPosted: Fri Jan 12, 2007 9:29 pm   
Thanks "Fang". I will try that for my "do" alias.

I'm not a programmer by trade ... built my database trigger by reading other examples and applying bits and pieces from here and there to it ... so I am struggling a bit with the last few issues.
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