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 ➜ Tips and tricks ➜ Auto-responder w/time spent idling

Auto-responder w/time spent idling

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


Posted by AnalogConspiracy   (9 posts)  Bio
Date Wed 17 Apr 2013 01:29 PM (UTC)

Amended on Wed 17 Apr 2013 01:30 PM (UTC) by AnalogConspiracy

Message
So, I'm desiring a script that, when I idle (idle is >= 5 minutes), will record the time spent idling, and enable some sort of trigger that will auto-respond to tells.

Player tells you 'Do you know Tyler Durden?'
(.+) tells you \'+\'

>Send("reply Sorry, %1. I've been idling for: ".. idletime ..". I'll respond to you when I am back at the keyboard. Thank you!")

I know idletime would be an LUA var, but that's what I'd want... Right? I know it's hard to write an example for this (As Nick tends to write examples in the requester's language, mine being LUA

Could I have some assistance in making this come to life? I'm kinda confused as to how I'd even start.

EDIT: Of course, just to give a clear definition, idling starts at >= 5 minutes, AND when no command has been entered into the MUD. It automatically removes itself the moment I enter a command.

-- Analog
Top

Posted by Oligo   (26 posts)  Bio
Date Reply #1 on Wed 17 Apr 2013 08:18 PM (UTC)

Amended on Wed 17 Apr 2013 08:19 PM (UTC) by Oligo

Message
I would start by using the socket object. This will help you do time calculations.


require "socket"
local currentclock = round(socket.gettime(),3)



Then programmatically determine when you last had an action. Must be a way programmatically to determine when you last entered input into the input text box. Store that in a variable, and do a


if (math.abs(currentclock - lastaction) >= 300) then
  Note("IM AFK")
end


That's a very rough shell, but that's how I'd approach it.

mud.arctic.org : 2700
Top

Posted by AnalogConspiracy   (9 posts)  Bio
Date Reply #2 on Wed 17 Apr 2013 08:29 PM (UTC)
Message
Well, I suppose we could start with setting an alias, as this seems to be the most obvious step.

 
<aliases>
  <alias
   match="^(.+)$"
   enabled="y"
   group="AFKstuff"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>Timerthing Disable
lastcommand = "%1"
Send("%1")
Timerthing Enable</send>
  </alias>
</aliases>


Now, I suppose we could add or create some sort of timer (a one-shot timer?)... I don't know the syntax for making, pausing, stopping, removing a timer or anything. But maybe this would be a start. And once the timer fires, I just throw a boolean in there.

afk = true

I don't know. Maybe I should just stop this and make a normal auto-respond trigger. At the same time, I don't want to just give up, because this would help expand my learning experience.

-- Analog
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #3 on Thu 18 Apr 2013 04:23 AM (UTC)

Amended on Thu 18 Apr 2013 04:28 AM (UTC) by Fiendish

Message
You don't need socket to get the time. There are utils.timer() and os.time() and os.date() already.

And yes, a timer and an alias are the way to go.
See http://www.mushclient.com/scripts/doc.php?function=DoAfterSpecial

Also, Lua is not an acronym and should not be written in all caps.

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

Posted by AnalogConspiracy   (9 posts)  Bio
Date Reply #4 on Thu 18 Apr 2013 06:54 AM (UTC)

Amended on Thu 18 Apr 2013 06:55 AM (UTC) by AnalogConspiracy

Message
Fiendish said:

You don't need socket to get the time. There are utils.timer() and os.time() and os.date() already.

And yes, a timer and an alias are the way to go.
See http://www.mushclient.com/scripts/doc.php?function=DoAfterSpecial

Also, Lua is not an acronym and should not be written in all caps.


Thank you for the response, Fiendish, as well as the correction. I shall refrain from treating it as an acronym.

How would I enable and disable the time?
Also, simply just setting (.+) with lastaction = "%1" Send("%1") isn't going to work. It seems to run all the commands twice, for example, if I run a direction with an IMAP GMCP plugin for a MUD, then it would send "south" and "imap". Is there anything we can do to rectify this problem?

[EDIT] How would we keep the time spent idling in a variable?

-- Analog
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #5 on Fri 19 Apr 2013 05:16 AM (UTC)

Amended on Fri 19 Apr 2013 05:22 AM (UTC) by Fiendish

Message
Maybe using http://www.mushclient.com/scripts/doc.php?function=AddTimer would be better than DoAfterSpecial. That way you can give the timer a name. You don't need to store the time spent idling. You need to store the timestamp when you started idling.

In a plugin, I guess you could do something like...


function OnPluginSent()
   went_idle_at = nil
   AddTimer ("idle_timer", 0, 5, 0, "", timer_flag.Enabled + timer_flag.OneShot + timer_flag.Replace, "goingIdle")
end

function goingIdle()
   went_idle_at = os.date()
end

https://github.com/fiendish/aardwolfclientpackage
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,647 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.