[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Command Throttling

Command Throttling

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


Posted by Mccane   (28 posts)  [Biography] bio
Date Tue 29 Apr 2008 12:23 PM (UTC)
Message
Oh the MUD I play, you have a limit of five commands per second. Any additional commands will cause three seconds of freeze time in which you can't do anything for five seconds. I have created somewhat of a buffer zone to prevent myself from stepping over this five command limit. I basically made a timer that sets the variable Buffer to 0 every 1 second. I then made an alias that matches * (everything). First it checks the Buffer variable. If the variable is greater than or equal to 5, the command will not be sent. If it less than 5, it will send the command, and then add 1 to Buffer. Here is the alias and timer:

<aliases>
  <alias
   match="*"
   enabled="y"
   send_to="12"
   keep_evaluating="y"
   sequence="1"
  >
  <send>Buffer = tonumber(GetVariable("Buffer"))
if (Buffer &gt;= 5) then
Note("Command not executed.  You have exceeded the buffer.")
else
Send("%0")
Buffer = Buffer + 1
SetVariable("Buffer", Buffer)
end</send>
  </alias>
</aliases>

<timers>
  <timer enabled="y" second="1.00"    send_to="12"
>
  <send>SetVariable("Buffer", "0")</send>

  </timer>
</timers>



Here is my dilemma. How can I incorporate this with my scripts without going through them all and adding in this buffer safety? Is there a way to make the Send function parse through this alias? Or is there some other method I could use to achieve the same result?

Thanks.
[Go to top] top

Posted by Cage_fire_2000   USA  (119 posts)  [Biography] bio
Date Reply #1 on Wed 30 Apr 2008 03:25 AM (UTC)
Message
How are you even sending 5 commands a second without cheating? Anyway, if you're using an alias to send multiple commands, you could use the send to speedwalk and then set the delay between commands to like 200 or above?
[Go to top] top

Posted by Mccane   (28 posts)  [Biography] bio
Date Reply #2 on Wed 30 Apr 2008 09:34 AM (UTC)
Message
It's not cheating to command stack or script on this MUD. It is a balance feature to prevent people from spamming in excess of five commands or command flooding. I considered using speedwalk, but the problem is sometimes I might want all five commands to go at once instead of a certain time frame apart. Additionally, unless I create some sort of script to prevent it, if I use speedwalk, even commands such as 'look' or 'inv', or 'who' will be delayed by the set time when I don't want them to be. I guess I might just have to go through my scripts and wherever anything is sent to the MUD, have it add something to the Buffer variable...
[Go to top] top

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #3 on Wed 30 Apr 2008 03:59 PM (UTC)

Amended on Wed 30 Apr 2008 04:00 PM (UTC) by Shaun Biggs

Message
If you want to have the command buffer automatically used, you can change the references in the script area. This may also break several scripts, but it does show a rough idea of how to set this up.


ReallySend = Send
Buffer = 0

Send = function( cmd )
  if (Buffer >= 5) then
    Note("Command not executed.  You have exceeded the buffer.")
  else
    ReallySend( cmd )
    Buffer = Buffer + 1
    SetVariable("Buffer", Buffer)
  end
end -- buffered Send


Actually, using something like this, you can set up a stack which will allow you to stack several commands and spit out the next 5 commands in a queue to the mud every second. Or as requested if you have not sent the maximum this second.

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #4 on Wed 30 Apr 2008 06:12 PM (UTC)
Message
You can make a plugin to trap OnPluginSend(), see if it can send stuff. If it can't send something, add it to a queue. Have a timer that fires every second, and try to resend the first value in the queue. However, if it CAN send something in the OnPluginSend(), you check to see if it is the first value in the queue and remove that.

Additionally you might want to make it so you consider stuff being in the queue a 'non-send' situation, and add it to the queue instead. That way you'd force proper ordening of your commands, although it would be a pain to butt in.

I could script it for you if you'd like, although it'd have to wait a few hours.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 30 Apr 2008 09:31 PM (UTC)
Message
Yes I agree with Worstje. See the documentation for OnPluginSend.

http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks

Each line that is being proposed to be sent would need to be checked, like this:


  • Check when the fifth-last line was sent. If the time of that is less than a second from now, queue the new line.
  • If it is OK to send the line, send it and also remember the time it was sent in a table which remembers the last 5 line times.


Then you also need a timer that fires fairly frequently (say, every half second) which checks if there are commands in the queue, and if so, and you haven't yet exceeded your limit of 5 commands in the last second, pulls out one or more items from the queue and sends it.

There was a similar post six months ago:

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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Thu 01 May 2008 12:08 AM (UTC)
Message
See this post:

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

I just wrote a plugin that should do what you need.

You won't need your alias any more, whatever you type is queued up, and then sent at an interval of 0.2 seconds per command, so you can't exceed 5 commands per second.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


22,520 views.

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

Go to topic:           Search the forum


[Go to top] 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.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]