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 ➜ Calculation in Variables

Calculation in Variables

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


Posted by Ventrilo   (10 posts)  Bio
Date Fri 14 Apr 2006 02:43 PM (UTC)
Message
Hi,

Could someone please help me on how to calculate with variants and triggers, then display it without having to use any scripts?

For example:
I want MushClient to capture the trigger on 'You have been saved.', count it to a variable named 'test', so whenever that text pops up, 'test' would have the counter.

What I've got so far:
Trigger works, output it to a var named 'test', altho 'test' only contains '+1' regardless of how many times that text pops up.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 14 Apr 2006 09:01 PM (UTC)
Message
Can you show us what you did? See:

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

- Nick Gammon

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

Posted by Ventrilo   (10 posts)  Bio
Date Reply #2 on Sat 15 Apr 2006 12:07 AM (UTC)
Message
This is what I've got:

<triggers>
<trigger
enabled="y"
match="^You have been saved."
send_to="9"
sequence="100"
variable="test"
>
<send>+1</send>
</trigger>
</triggers>


It's just a test on what I'll try to expand without programming/scripting knowledge (e.g: level up calculation, etc.)

Thanks Nick!
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 15 Apr 2006 08:53 AM (UTC)
Message
This is how I would do that. You need to enable scripting and make Lua your scripting language.

For more details about doing that, see:

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




<triggers>
  <trigger
   custom_colour="3"
   enabled="y"
   match="^You have been saved\.$"
   regexp="y"
   send_to="12"
   sequence="100"
   variable="test"
  >
  <send>
SetVariable ("test", (GetVariable ("test") or 0) + 1)
Note ("Saved count is now " .. GetVariable ("test"))
</send>
  </trigger>
</triggers>



The "or 0" part allows for the initial case of the variable not existing.

Your trigger looked like a regular expression (with the ^ at the start) but you had not checked the "regular expression" box.

- Nick Gammon

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

Posted by Ventrilo   (10 posts)  Bio
Date Reply #4 on Sat 15 Apr 2006 09:19 AM (UTC)
Message
Thanks Nick,

I read about your post on the Lua script and did the following:
I opened immediate window on MushClient and paste your solution, after I've chosen Lua as my script preference. Altho when i ran the script it says:

Error number: 0
Event: Compile error
Description: [string "Immediate"]:1: unexpected symbol near `<'
Called by: Immediate execution

Thanks
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Sat 15 Apr 2006 09:03 PM (UTC)
Message
Read this post:

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

Only part of that was the script, the rest was a trigger in the XML format used by MUSHclient.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


21,288 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.