Gammon Forum
Entire forum
MUSHclient
General
Redefined functions, in particular Send, Send to World and the command line
Redefined functions, in particular Send, Send to World and the command line
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Cino
Australia (17 posts) bio
|
Date
| Mon 16 Jan 2006 12:56 AM (UTC) |
Message
| I have made an idle counter, as you appear to the MUD (so based on the last command sent) as opposed to the last command entered clientside.
I have a somewhat functioning implementation, using a redefined version of Send,
OldSend=Send
function NewSend(...)
for i,v in ipairs(arg) do
OldSend(v)
end
option.idle=os.time()
end
Send=NewSend
as inspired from http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5434
and an alias,
<aliases>
<alias
match="^((?<!/)|(?<!#)).*$"
enabled="y"
regexp="y"
send_to="12"
sequence="999"
>
<send>Send("%0")</send>
</alias>
</aliases>
This catches everything that does not begin with '/' (for script command), '#' (the chat plugin) or is another alias as it has the latest sequence in my list.
Between them, they appear to catch every sent command (be it from the command line or a macro), except when something uses the 'Send to World' option.
Of course, a work around for the 'Send to World' is to instead 'Send to Script' or 'Send to Execute', and just use Send...
I was wondering if there was a way to redefine the send from command line and 'Send to World' to use this new Send, without having to go through the extra alias or sending to script or execute.
Just so you know where I end up with all this, here is my status bar
function StatusBar()
local sb
sb="Idle: "..TimeSince(option.idle)
--sb=sb..whatever_else_I_deem_useful_to_display
--sb=sb..etc
SetStatus(sb)
end
which is called from a timer to update every second. | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #1 on Mon 16 Jan 2006 02:22 AM (UTC) |
Message
| My first reaction is that it would be simpler to make a small plugin which uses OnPluginSend callback.
This detects *all* text sent to the MUD, including timers, triggers etc.
Thus, this is the logical place to capture the time from the MUD's point of view.
See:
http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks
Your other problem is this:
for i,v in ipairs(arg) do
OldSend(v)
end
Send actually appends a newline to the text, as it assumes you want to send something with a newline at the end. The documentation doesn't mention this (yet), but it does say multiple arguments are concatenated together.
Unfortunately your approach of doing multiple OldSend calls would actually break up the command being sent and put a newline after each piece of it.
If you are going to stick to your function you should concatenate the "arg" arguments together and then do a single OldSend. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Cino
Australia (17 posts) bio
|
Date
| Reply #2 on Mon 16 Jan 2006 03:44 AM (UTC) |
Message
|
Quote:
Unfortunately your approach of doing multiple OldSend calls would actually break up the command being sent and put a newline after each piece of it.
Ah yes, I hadn't noticed that. I had been concatenating the components and only sending one argument anyways thus far.
But OnPluginSend is perfect for this case.
Thank you. | 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.
10,612 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.