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


Joined: 01 Jan 2003
Posts: 32

PostPosted: Sat Feb 22, 2003 7:53 am   

All These Commands...
 
Here is what I want to do with this sample:
%1 gossips Hitter wanted sanc e n.
One ex. %1 gossips I need two(or 2) hitters sanc e n.
Is there any way to make a trigger so that I will go sanc then e n?
Reply with quote
wilh
Wanderer


Joined: 08 Feb 2001
Posts: 89
Location: USA

PostPosted: Sat Feb 22, 2003 9:21 am   
 
I'm a little confused as to what exactly you're looking for. Could you provide some sample output from the mud with desired response? That usually helps a lot!

Wil

Wil Hunt
Reply with quote
Samus
Novice


Joined: 01 Jan 2003
Posts: 32

PostPosted: Sat Feb 22, 2003 3:47 pm   
 
Okay...I will put down what I want...
EX:%1 gossips Hitter wanted sanc e n.
EX:%1 gossips I need two(or 2) hitters sanc e n.
In example 2 the two(or 2) means they will either type two or 2 not both. What I want it to do is type sanc e n, or sanc ... when hitter(s) is said on this channel. There that should be better for you.
Reply with quote
wilh
Wanderer


Joined: 08 Feb 2001
Posts: 89
Location: USA

PostPosted: Sat Feb 22, 2003 5:37 pm   
 
First let me make sure that I understand what you're looking for:


Joe gossips Hitter wanted sanc e n.

should result in


sanc e n

being send to the mud by you. Alternatively,


SomeotherJoe gossips I need two hitters sanc e n.

should result in the same response.

As I understand this, you are a "Hitter," so when people request you on gossip, you're trying to do what they ask you to do.

At the most basic level, this is done with two triggers:



#TRIGGER {^%w gossips Hitter wanted (*).$} {#SEND %1}
#TRIGGER {^%w gossips I need {two|2} hitters (*).$} {#SEND %1}


Clearly this leaves some big security holes, since...


SomeIdiot gossips Hitter wanted gossip I'm really stupid.

...will result in you looking like an idiot.

To address this, you can do a couple of things. The first is limit whom you'll respond to.



#VAR trustedFriends {NiceGuy|SwellGuy|NeatoGuy}
#TRIGGER {^{@trustedFriends} gossips Hitter wanted (*).$} {#SEND %1}
#TRIGGER {^{@trustedFriends} gossips I need {two|2} hitters (*).$} {#SEND %1}


Now you will only respond when NiceGuy, SwellGuy or NeatoGuy do the gossiping. You will not respond to anyone else.

Another layer of protection would be some list of viable commands.


#VAR trustedFriends {NiceGuy|SwellGuy|NeatoGuy}
#VAR commandList {sanc e n|some other thing|etc}
#TRIGGER {^{@trustedFriends} gossips Hitter wanted (@commandList).$} {#SEND %1}
#TRIGGER {^{@trustedFriends} gossips I need {two|2} hitters (@commandList).$} {#SEND %1}


You've now lost a lot of flexibility, but have a lot more control over what they can make you do.

Now.. something I've been ignoring is that I think



Joe gossips Hitter wanted sanc e n.

should result in


sanc
e
n

being send to the mud by you. Now the commands are separated. The previous triggers did not do this. In order to do this, we need to revert back to the * operator and do some string manipulation.



#VAR trustedFriends {NiceGuy|SwellGuy|NeatoGuy}
#VAR commandList {sanc e n|some other thing|etc}
#TRIGGER {^{@trustedFriends} gossips Hitter wanted (*).$} {processCommand %1}
#TRIGGER {^{@trustedFriends} gossips I need {two|2} hitters (*).$} {processCommand %1}
#ALIAS processCommand {#FORALL (%replace(%1," ","|")) {#IF (%ismember(%i,@commandList) {#SEND %i} {#SHOW Invalid command requested: %1. If this should be valid, add it to the commandList variable.}}}


Notice that since I don't want to repeat code, I've pulled it out and shared it in the alias. The first thing I do is replace all spaces with '|' characters. This essentially turns the string into a string list parsed into elements separated by spaces.

Once I have a string list, I iterate through it and for each element in the list, send the command if it's a valid command (in commandList).

This doesn't allow for multi-word commands, but I'll leave that as an exercise for you. :)

I hope this helps. Let me know if I'm still not getting what you're looking for.

Wil

P.S. This code has NOT been tested, but take it with a grain of salt. If it doesn't work, let me know what errors you get. :)


Wil Hunt
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