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 ➜ Counting time between lines

Counting time between lines

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


Posted by Svet   (4 posts)  Bio
Date Sat 09 Mar 2013 08:37 AM (UTC)
Message
I want to count the time (in seconds) between two lines, which appear in my output window, and then store it in a variable. The counter should start at the first line, then stop and store the elapsed time at the second line. How do I do this?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 09 Mar 2013 09:54 AM (UTC)
Message
Make two triggers?

http://www.gammon.com.au/scripts/doc.php?lua=utils.timer

- Nick Gammon

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

Posted by Svet   (4 posts)  Bio
Date Reply #2 on Sat 09 Mar 2013 05:26 PM (UTC)
Message
This is what I did, but it still doesn't work:

<triggers>
<trigger
enabled="y"
expand_variables="y"
match="^([[:alpha:]]+) brings back (her|his) arm\, locking eyes with you"
regexp="y"
send_to="12"
sequence="100"
>
<send>check_fury = utils.timer ()</send>
</trigger>
</triggers>

<triggers>
<trigger
enabled="y"
match="^([[:alpha:]]+) hurls ([[:alpha:]]+) at you\, which returns to (her|his) hand\. You"
regexp="y"
send_to="12"
sequence="100"
>
<send>time_fury = utils.timer () - check_fury</send>
</trigger>
</triggers>

The variables don't get the new values. Can you help me?
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #3 on Sat 09 Mar 2013 05:59 PM (UTC)

Amended on Sat 09 Mar 2013 06:01 PM (UTC) by Fiendish

Message
Quote:
This is what I did, but it still doesn't work:

Do your triggers fire at all? That's the first step, but we can't tell from what you wrote.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Svet   (4 posts)  Bio
Date Reply #4 on Sat 09 Mar 2013 06:30 PM (UTC)
Message
I tested my triggers and they do fire.
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #5 on Sat 09 Mar 2013 06:56 PM (UTC)
Message
Good. Now try using SetVariable/GetVariable instead of local variables.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 09 Mar 2013 08:40 PM (UTC)
Message
Svet said:

This is what I did, but it still doesn't work:
...
The variables don't get the new values. Can you help me?


How do you know? How did you display the variables?

- Nick Gammon

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

Posted by Svet   (4 posts)  Bio
Date Reply #7 on Sun 10 Mar 2013 06:17 AM (UTC)
Message
To Nick Gammon: I tested the triggers a few times with different time interval between them. After each test, I glanced at World Properties... > Scripting > Variables to see the value of my variables, but they always stood with the default value.

I updated my triggers and now I use SetVariable/GetVariable as Fiendish suggested. I did a test with my triggers as follows:

<triggers>
<trigger
enabled="y"
match="^([[:alpha:]]+) brings back (her|his) arm\, locking eyes with you"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("check_fury", "utils.timer ()")
DoAfter (math.floor (GetVariable ("time_fury") - 0.5), "duck")</send>
</trigger>
</triggers>

<triggers>
<trigger
enabled="y"
match="^([[:alpha:]]+) hurls ([[:alpha:]]+) at you\, which returns to (her|his) hand\. You"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("time_fury", "utils.timer () - check_fury")</send>
</trigger>
</triggers>

During this test my "check_fury" variable updated with "utils.timer ()" value and my "time_fury" variable remained unchanged. Then, I removed the quotes:

<triggers>
<trigger
enabled="y"
match="^([[:alpha:]]+) brings back (her|his) arm\, locking eyes with you"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("check_fury", utils.timer ())
DoAfter (math.floor (GetVariable ("time_fury") - 0.5), "duck")</send>
</trigger>
</triggers>

<triggers>
<trigger
enabled="y"
match="^([[:alpha:]]+) hurls ([[:alpha:]]+) at you\, which returns to (her|his) hand\. You"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("time_fury", utils.timer () - check_fury)</send>
</trigger>
</triggers>

This time my "check_fury" variable updated with "128839.22926007" value and my "time_fury" variable remained unchanged again.
Top

Posted by Fiendish   USA  (2,537 posts)  Bio   Global Moderator
Date Reply #8 on Sun 10 Mar 2013 04:05 PM (UTC)

Amended on Sun 10 Mar 2013 04:17 PM (UTC) by Fiendish

Message
It looks like you're complicating things a bit. Going back to what you originally posted, try this modification...


<triggers>
<trigger
enabled="y"
expand_variables="y"
match="^([[:alpha:]]+) brings back (her|his) arm\, locking eyes with you"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("check_fury", utils.timer())</send>
</trigger>
</triggers>

<triggers>
<trigger
enabled="y"
match="^([[:alpha:]]+) hurls ([[:alpha:]]+) at you\, which returns to (her|his) hand\. You"
regexp="y"
send_to="12"
sequence="100"
>
<send>time_fury = utils.timer() - GetVariable("check_fury"))</send>
</trigger>
</triggers>



https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #9 on Sun 10 Mar 2013 10:05 PM (UTC)
Message
Svet said:

To Nick Gammon: I tested the triggers a few times with different time interval between them. After each test, I glanced at World Properties... > Scripting > Variables to see the value of my variables, but they always stood with the default value.


You don't have to use get and set variable, but you do need to understand about the different types of variables.

http://www.gammon.com.au/forum/?id=10863

- 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.


26,316 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.