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.
 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ Confusion with variables

Confusion with variables

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


Posted by Calimun   (10 posts)  Bio
Date Thu 23 Jun 2005 11:04 AM (UTC)
Message
Okay, this is kinda hard for me to explain, but I'll try my best.

I got the client set-up so that my MUCK will append certain lines to a log. Important things, like whispers, tells, people looking at my character, etc. But I ran into something else. Poses, for example.

Calimun does something stupid.

They don't have anything special about them, except that the first word is always going to be the character's name.

So I thought, 'What if I make a trigger that checks a text file, or some other Variable for friend's names, so that the log only gets poses from friends.' I'll need some way to, not only make this trigger and variable, but another trigger that adds friend's names from the muck into the variable list.

Help?
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Thu 23 Jun 2005 06:17 PM (UTC)
Message
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4603

and

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4415

You basically make a variable that acts as a regexp type thing. Then you don't have to check via scripting, but your trigger will check automatically.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Calimun   (10 posts)  Bio
Date Reply #2 on Thu 23 Jun 2005 11:25 PM (UTC)
Message
I read through the pointed-out topics, and I tried out a few different things. But I think I'm missing the whole picture. I never worked with Regular Expression before, and I only had previous experiance with varibles with a few things.

Can someone baby-step me through this? x.x; Maybe try and explain this to me so I can understand and learn what I'm doing. ^^;

Right now, I have it set so that one trigger matches:

> Adding player "*"

But when I tried to send it to variable friendlist:

|%1

It just resets it into the playername with a OR sign in front.

That, and I'm having trouble with the other part, the trigger that matches names from the friendlist variable. Regular Expression just confuses me. ;.;
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #3 on Fri 24 Jun 2005 12:26 AM (UTC)

Amended on Sat 25 Jun 2005 02:30 AM (UTC) by Flannel

Message
You need to append the new name (with the pipe) to the old contents of the variable.

In VBScript, this is the snippet to add to your list:
setvariable "charlist", getvariable("charlist") & "|%1"

and then... for your trigger, you just have (@!charlist) as a match (whereever you want any name). Which means the charlist variable, and then the ! means not to parse it (as in, don't escape special characters, like the pipes), but your whole match text will have to be a regular expression.

Heres an example:
<aliases>
  <alias
   match="^addfriend (.*)$"
   enabled="y"
   echo_alias="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>setvariable "friendlist", getvariable("friendlist") &amp; "|%1"</send>
  </alias>
</aliases>

<variables>
  <variable name="friendlist">Calimun|Flannel</variable>
</variables>

<triggers>
  <trigger
   custom_colour="9"
   enabled="y"
   expand_variables="y"
   ignore_case="y"
   keep_evaluating="y"
   match="(@!friendlist)"
   regexp="y"
   repeat="y"
   sequence="50"
  >
  </trigger>
  <trigger
   enabled="y"
   expand_variables="y"
   ignore_case="y"
   keep_evaluating="y"
   match="^(@!friendlist) (.*)$"
   regexp="y"
   send_to="12"
   sequence="50"
  >
  <send>note "log: %0"</send>
  </trigger>
</triggers>


There is an alias (as a regexp, just so you could see how regexps look) which adds a name to the friendlist (which does need to be initialized to at least one name, since otherwise you will add your first name, and have the variable be "|bob" which will match on 'bob' or '' (empty string) which isn't good).

There are TWO triggers, one matches any person in your friend list, and colors it, the other matches any line that starts with a friend (and then a space), and note's it back (you can add your own log command). Of course, this will match on a LOT of lines (bob attacks jane, bob dances, bob disconnects) so you might want to rethink that.
And they are set to a lower sequence (with keep evaluating checked) so they can hopefully not interfere with any other triggers, and still catch everything before other triggers. They have expand variables checked, and are regexps. And ignore case is set, just because. If you are real careful with case when setting your list, you'll be alright without it. But bob and Bob are different things, when it comes to triggers.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Calimun   (10 posts)  Bio
Date Reply #4 on Fri 24 Jun 2005 10:50 AM (UTC)
Message
Cool, thanks!

Everything is working. Well...almost everything. The only thing that's not working for me is the alias. The script code keeps giving me errors, and everytime I attempt a fix, another error pops up. This:

setvariable "friendlist", getvariable("friendlist" &amp; "|%1")

This gave me a missing ")" error, so I googled it up and I took out amp; and just left &. Another error came up, something about mismatch setvariable. So I quoted everything after getvariable. So now it looks like this:

setvariable "friendlist", "getvariable("friendlist" & "|%1")"

But now I get the error of Expected end of statement at column 41

Now I think I'm stuck. x.x;
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #5 on Fri 24 Jun 2005 01:13 PM (UTC)

Amended on Fri 24 Jun 2005 01:14 PM (UTC) by Larkin

Message
The &amp; is there because that's how it is saved in your world file. XML formats certain special characters like this. The snippets that Flannel posted were meant to be pasted directly into your Triggers and Aliases dialogs. You can highlight the text here (including the "aliases" and "triggers" element around the whole thing) and then use the Paste button on each of these dialogs to get the settings into your world settings.
Top

Posted by Calimun   (10 posts)  Bio
Date Reply #6 on Fri 24 Jun 2005 01:17 PM (UTC)
Message
I realized that after I posted, and that's what I did. I'm still getting the VBScript errors.
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #7 on Fri 24 Jun 2005 02:28 PM (UTC)
Message
Don't put quotes around getvariable when setting the variable.
Top

Posted by Calimun   (10 posts)  Bio
Date Reply #8 on Fri 24 Jun 2005 03:30 PM (UTC)
Message
I didn't. I copy-pasted what Flannel has typed, as you told me to, and it still gives me scripting errors.
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #9 on Fri 24 Jun 2005 05:53 PM (UTC)
Message
You misunderstand me. What Flannel posted has no quotes around the entire call to getvariable. Your post has quotes there, however. Remove the extra set of quotes and try it again.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #10 on Fri 24 Jun 2005 06:15 PM (UTC)
Message
Why dont you copy and paste the alias you have? So we can know exactly what you have, and what you dont. (Copy and paste, from the alias dialog, just like what you did to put it there... well, just the opposite).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Calimun   (10 posts)  Bio
Date Reply #11 on Fri 24 Jun 2005 08:29 PM (UTC)
Message
<aliases
muclient_version="3.65"
world_file_version="15"
date_saved="2005-06-24 15:36:56"
>
<alias
match="^addfriend (.*)$"
enabled="y"
echo_alias="y"
regexp="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>setvariable "friendlist", getvariable("friendlist" &amp; "|%1")</send>
</alias>
</aliases>

This is what I copy-pasted before, and I pulled it from my World file. There's no quotes around getvariable, which is what I was trying to say before. >.<
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #12 on Sat 25 Jun 2005 12:35 AM (UTC)
Message
I see the problem now. You need to move the addition of the name to outside of the getvariable call. You only want to specify the name of the variable to retrieve and THEN add the name to the value to be stored back in it.

setvariable "friendlist", getvariable("friendlist") &amp; "|%1"


(I think that's right, but I don't use VBscript myself.)
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #13 on Sat 25 Jun 2005 02:29 AM (UTC)
Message
Yeah. Thats right. I have edited my post to correct it. Sorry about that, no idea how it happened.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Calimun   (10 posts)  Bio
Date Reply #14 on Sat 25 Jun 2005 10:49 AM (UTC)
Message
It works now, thanks!

I did alter it a bit tho. Now instead of a alias, I made it a trigger that looks for players added to my in-muck friendlist. So whoever I add in-game, is added to my client friendlist. ^^
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.


41,537 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.