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


Joined: 13 Sep 2006
Posts: 4

PostPosted: Wed Sep 13, 2006 2:18 am   

Simple Scrip Requests- New Problem Please Help
 
Could someone explain how to do a couple of things for me?

I want to create a script so that if someone issues one of several strings, I will reply with a string that matches what they issue me.

For example,
I know I need two variables with all of the strings. Say I have three strings that can be issued: hi there, go away, come closer; and three strings that can be returned: yes, no, ok;

How do I set up a trigger that will do the following:
Person tells you 'go away' ; reply 'no'

I tried looking at triggers that were designed to do this, but I was utterly confused by them :(


Last edited by jcc27 on Thu Sep 14, 2006 4:03 am; edited 1 time in total
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Wed Sep 13, 2006 4:21 am   
 
Depending on how many things you want to reply to automatically, it can be easier to just set it up in triggers:
Code:
#TRIGGER {Person tells you 'go away'} {reply no}

If you only need a few responses this is by far the easiest way to do it.

Otherwise you can set it up in a record variable with what they will say to you as a key and your reply as the value... open up the settings editor, create a new variable, underneath the Name box click on the Data Record box, fill in the things you want to respond to on the left and the responses you want on the right.

Then set up a trigger with something like:
Code:
#REGEX {^Person tells you '(.*)'$} {#if %iskey( @REPLIES, %1) {reply @{REPLIES.%1}}}

Where REPLIES is the name of your variable. Note the extra {} needed around @{REPLIES.%1} in order for it to expand correctly.

Edit: Capitalization inconsistencies.
Reply with quote
jcc27
Newbie


Joined: 13 Sep 2006
Posts: 4

PostPosted: Wed Sep 13, 2006 2:35 pm   
 
Thanks so much!
Reply with quote
jcc27
Newbie


Joined: 13 Sep 2006
Posts: 4

PostPosted: Wed Sep 13, 2006 7:27 pm   
 
Okay I'm having problems now with the code you gave me...

So if my variable has, for instance, "go away" with a response as "no", the trigger will just reply with the last part of the prompt statement. In this case, it does "reply away". If the prompt was "hi there how are you", it would reply "there how are you".

Why isn't it selecting the second box of the data record instead of part of the first box? Here is the trigger, same as yours:

tells you '(.*)'$
#if %iskey( @Scrolls, %1) {reply @{Scrolls.%1}}
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Sep 14, 2006 10:10 am   
 
It is because of the spaces. You need to use the %db function properly grab the value from the key. I would suggest this much shorter trigger.
#TRIGGER {tells you '({@Scrolls})'$} {reply %db(@Scrolls,%1)}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
jcc27
Newbie


Joined: 13 Sep 2006
Posts: 4

PostPosted: Fri Sep 15, 2006 2:24 pm   
 
It works now. Thanks again for the help you all :)
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