Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Comparing Variables

Comparing Variables

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Kurapiira   (25 posts)  Bio
Date Fri 05 Mar 2010 05:30 AM (UTC)
Message

Sorry, cant find info or figure this out...

trying to make a Master / Slave bot thing.

I want the bot to do actions only the Master says.

trigger:

^(.*?) says\, \"(.*?)\"$

Value:

if (%1) == @master then
Send ("%2")
else
Send ("scoff")
end

it does actions Anyone says...
not comparing %1 to the Master variable?

Thanks for any help...
K.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 05 Mar 2010 05:34 AM (UTC)
Message
It literally substitutes, so you are getting something like:


if (John) == Kurapiira then


That is comparing two variables. You need something like:


if "%1" == "@master" then


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kurapiira   (25 posts)  Bio
Date Reply #2 on Fri 05 Mar 2010 06:00 AM (UTC)
Message
Thanks for the help and quick response!

Now its bypassing the first part and just sending
"Scoffs"

I've tried quotes and brackets..is it spacing or something?...
checked regular expression, expand variables, keep evaluating...

dunno...kinda weird

K.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #3 on Fri 05 Mar 2010 06:07 AM (UTC)
Message
What's the value of the messages variable? Make sure it's set.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 05 Mar 2010 06:15 AM (UTC)
Message
Template:what Please help us by showing:
  • A copy of the trigger, alias or timer you were using (see Copying XML)
  • The error message, if any, that you got

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kurapiira   (25 posts)  Bio
Date Reply #5 on Fri 05 Mar 2010 06:17 AM (UTC)
Message

I did this...just to see if it's capturing right


Send ("' %1")
Send ("' %2")
if "%1" == "@master" then
Send ("%2")
else
Send ("scoff")
end

its capturing the name of the person
and its sending both the name and the command they say

ie: glinka says,"sit"

You say glinka
You say sit

just cant get the comparison ...
Top

Posted by Kurapiira   (25 posts)  Bio
Date Reply #6 on Fri 05 Mar 2010 06:19 AM (UTC)
Message
<triggers>
<trigger
enabled="y"
expand_variables="y"
keep_evaluating="y"
match="^(.*?) says\, \&quot;(.*?)\&quot;$"
regexp="y"
send_to="12"
sequence="100"
>
<send>Send ("' %1")
Send ("' %2")
if "%1" == "@master" then
Send ("%2")
else
Send ("scoff")
end
</send>
</trigger>
</triggers>
Top

Posted by Kurapiira   (25 posts)  Bio
Date Reply #7 on Fri 05 Mar 2010 06:22 AM (UTC)
Message
<variables>
<variable name="master">glinka</variable>
</variables>
Top

Posted by Kurapiira   (25 posts)  Bio
Date Reply #8 on Fri 05 Mar 2010 06:25 AM (UTC)
Message
sorry to be so dense...the master variable wasn't capitalized..seems to work now

Thanks for the help folks !
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #9 on Fri 05 Mar 2010 06:27 AM (UTC)
Message
You can try string.lower() in your comparisons, too. :)

if string.lower("%1") == string.lower("@master") then

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


27,842 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.