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
AragonT2T
Newbie


Joined: 29 Nov 2006
Posts: 4

PostPosted: Wed Nov 29, 2006 6:19 am   

Hunt Trigger
 
Ok here is my problem,

Im trying to make a hunt trigger so that when someone leaves a direction i will immediately follow. I did it the hard way and set up several triggers so that when it says <player> leaves north i will go North. The problem comes when they leave northwest I will automatically leave north instead of going northwest. Is there a command that will allow me to trigger nw instead of going north?
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Wed Nov 29, 2006 7:02 am   
 
change it to north~.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Nov 29, 2006 8:27 am   
 
The easiest way would probably be to make one trigger:

#trig {^(%w) leaves (%w)} {#if (%1=@target) {#send %2}}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Nov 29, 2006 5:52 pm   
 
You definitely did do it the hard way.

You should have only set up one trigger, and that's the trigger that Fang Xianfu suggested. The only problem with that is if your MUD interpets "northwest" as "north."

The only thing you'd have to do in the future is change the variable target to the player's name. You can accomplish this by typing:

#var {target} {charneus}

Then whenever I left the room, you would follow me. If you have several players that you like to follow, you can set them up in a database and use the %ismember command. Then you would set it up as follows:

#var {target} {charneus|fang|chris}
#trig {^(%w) leaves (%w)} {#if (%1=%ismember(@target)) {#send %2}}

That is untested, but it should work, unless I'm missing something. What that would do is check to see if the player who leaves is included in the variable target. If the name is in the variable, it follows the person. If it isn't, then you stay right where you are. Very easy compared to making several triggers to follow several people.

Now comes the hard part. If your MUD interprets "northwest" as "north" only, then you'll want to rework the trigger. Easiest way that comes to my mind is this:

#trig {^(%w) leaves (%w)} {#if (%1=%ismember(@target)) {#var {ldir} {%2};hunt}
#alias {hunt} {#if (@ldir=north) {#send north} {};#if (@ldir=south) {#send south} {};#if (@ldir=east) {#send east} {};#if (@ldir=west) {#send west} {};#if (@ldir=northwest) {#send nw} {}; #if (@ldir=northeast) {#send ne} {};#if (@ldir=southwest) {#send sw} {};#if (@ldir=southeast) {#send se}}

That's also untested, but try it out if you need to.

I hope that this has been of some help to you.

Charneus
Reply with quote
AragonT2T
Newbie


Joined: 29 Nov 2006
Posts: 4

PostPosted: Thu Nov 30, 2006 1:28 am   
 
Ok would i set this up in a class folder? And also it looks like im getting syntax errors at the {#if part.

Im sorry.. i am a total newb when it comes to scripting.

Oh and the mud i play is going to require the second script b/c it does interpret northwest as north.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Nov 30, 2006 8:45 am   
 
It doesn't matter where you put the trigger and alias, though putting them in their own class might help you to remember where they are and what they do. As long as they're somewhere, you're good.

Where exactly is the syntax error?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Nov 30, 2006 5:45 pm   
 
Actually, I made a couple of errors, and now that I've had a chance to fix them, I've done so. And you don't have to put them in a class folder, but as Fang said, if it's easier for you to do so, you can.

The syntax error will occur depending on how you put them in. If you're using the Settings Editor (easiest way, in my opinion) and you copy/pasted the information, the brackets before the #if command would create a syntax error. The following is the code you'll want to use, and again, I suggest doing it through the settings editor. In case you're not aware of how to work it, I'll give you step by step instructions.

First, go to your Settings Editor. Just click on the Triggers button at the top of your screen. Once you're in there, click 'New' and it'll generate a new trigger for you. All that's left for you to do is fill in the blanks.

In the field that says 'Pattern:', you'll put the trigger pattern there. In this case, it's:

Code:
^(%w) leaves (%w)


Then skip on down to the 'Value' field (no need to worry about anything else). In this box, you can paste the following into it:

Code:
#if (%ismember(%lower(%1), @target)) {
#var ldir {%2}
hunt
}


Next, we will create the alias for 'hunt'. To do this, click on the down arrow to the side of the 'New' button. This will give you a list of items to choose from. Choose 'New Alias'. Just like it did with a new trigger, it will generate a new alias for you. It's up to you to fill in the pattern. In the 'Name' field, enter:

Code:
hunt


Then in the 'Value' field, paste the following:

Code:
#if (@ldir=north) {#send north} {}
#if (@ldir=south) {#send south} {}
#if (@ldir=east) {#send east} {}
#if (@ldir=west) {#send west} {}
#if (@ldir=northwest) {#send nw} {}
#if (@ldir=northeast) {#send ne} {}
#if (@ldir=southeast) {#send se} {}


Now your alias and your triggers are set. Now we just have to do your variable. Again, I'm not sure if you're planning on using several people as a target, but the easiest way to input names (in my opinion) is through the command line. There, you would just type:

Code:
#variable {target} {charneus|fang|chris|blah|bleh|bluh|ugh|...}


As long as you have a '|' between each name, you can add as many names to that list that you want. Then, in the future, if you want to update the names in there, you can go to your settings editor and change the names there. It'll appear as a string list, and all you'll have to do is remove the names you don't want, or add names you do want. For ease of typing, you don't have to capitalize the first letter of each name. In fact, it's preferable if you don't. Otherwise, you won't get a response when the trigger fires. It's going to look for a lowercase string.

If you have any other problems with this, drop me an email. My email address is charneus@gmail.com. I hope this works out for you, though.

Charneus
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Tue Dec 05, 2006 5:15 am   
 
Isnt this all kind of overcomplicating things?

Here's an easy one line solution.

Code:
#TRIGGER chase {^@player leaves &%w~.} {%exec(%1)}


Similar to Fang Xianfu's solution, but faster i'd think since there's no #IF

also, lets make a nice easy toggle switch so you can turn this on and off

Code:
#ALIAS chase {@temp1 = %1;#IF @temp1="on" {#T+ chase;#ECHO Chasing @player !};#IF @temp1="off" {#T- chase;#ECHO Stopped Chasing!}}


now "chase on" will turn it on
and "chase off" will turn it off

nice and easy

Let me know how it works for you
_________________
Rufus- Winner of Stuff
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Dec 05, 2006 10:57 am   
 
EDIT: Oh dear, I didn't notice that this was in the zMUD forum rather than the CMUD forum. Well, if you ever upgrade, you've got something else to try :P I still think it'd be wise to add a check of %numparam() before you check whether the parameter is on or off to see if you've sent a parameter - and if not, to toggle it using %trigger. It allows you to use the alias without taking the extra time to specify on or off.

I didn't realise you can use variables for expansion in trigger patterns. Very useful, and the first part of that works just fine provided you capture the wildcard:

#trig chase {^@player leaves ($dir:%w).} {#exec {$dir}}

I'm pretty sure you have to use the command #exec rather than the function %exec - most functions don't work on their own, you have to do something with them. The second one can be simplified more if you use a named parameter and the #switch command, though:

#alias chase($status) {#switch ($status) (on) {#t+ chase;#echo Chasing @{Player}!} (off) {#t- chase;#echo Stopped chasing} {#if (%trigger(chase)) {#t- chase;#echo Stopped chasing!} {#t+ chase;#echo chasing @{player}!}}}

and then complicated more by adding an "else if" command to toggle chasing if a parameter that isn't "on" or "off" is given. Makes it faster to type.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Dec 14, 2006 7:10 pm   
 
Quote:

Isnt this all kind of overcomplicating things?


Actually, it's not complicating things at all. Read his response - his mud assumes "northwest" means "north" and therefore needs the second part that I put in there. The trigger works perfectly, as far as I'm concerned. But if you can design one that allows "northwest" to be read as "northwest" and not "north," then please, enlighten us. :)

Charneus
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Thu Dec 14, 2006 7:32 pm   
 
that problem is corrected with the inclusion of the period in the trigger
_________________
Rufus- Winner of Stuff
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Dec 14, 2006 8:06 pm   
 
How is it corrected?

Given-
Charnues leaves northwest. -returns %exec(northwest)

Even with your trigger, it's going to read "northwest" as "north". His mud is unique in that if he wants to go northwest, he -HAS- to type 'nw', not 'northwest' because the mud will interpret that to read as 'go north'.

Again, that's why there's the need for the alias.

Charneus
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Thu Dec 14, 2006 8:36 pm   
 
Charneus, if the situation was as you say, then you are right. I think you are being misled by a sloppily typed question though. The last line led me to believe that he was comparing nw to north, as opposed to nw to northwest. Anyways, i see what you are talking about now, and I think we're on the same page.

On that note, I find it very hard to believe that his mud functions any other way than what I descriped.
_________________
Rufus- Winner of Stuff
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Dec 15, 2006 7:19 pm   
 
umdbandit,

I knew you weren't stupid or anything, and I'm glad we cleared the issue. I also find it very odd that his mud would interpret "northwest" as "north" because I would assume the mud would check for any arguments past "north". But, as he stated (quoted below), this doesn't seem to be the case.
Quote:

Oh and the mud i play is going to require the second script b/c it does interpret northwest as north.


Have fun creating more bots (per the Trigger Assistance post) :P

Charneus
Reply with quote
umdbandit
Wanderer


Joined: 31 Oct 2004
Posts: 94

PostPosted: Fri Dec 15, 2006 8:38 pm   
 
Thanks Charneus :)

And Happy Holidays!
_________________
Rufus- Winner of Stuff
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