This is a module I wrote to help cut down on system spam. It is extremely flexible for its simplicity. To use it, I recommend installing it via Mudlet's Package Manager (Toolbox > Package Manager).
Download link at: http://www.mercymyqueen.com/aetolia/Universal Throttle.mpackage
How Throttling Works
This module provides you with a function, attempt()
, which will try to send any command or function, after first checking its throttle status. If the action has been throttled, it will do nothing until the throttle clears. Otherwise, it sends the action as normal.
As an example: The user attempts an action with the ID "bash", which on execution will simply send "punch target". The first time the user attempts this, the action "bash" is placed into the throttle_registry table. A timer is set for 0.2 seconds, executing the unthrottle() function when it expires. The user's system continually spams "bash" attempts, but because the "bash" action is registered, nothing gets through. The timer expires, runs its function, and clears "bash" from the registry. The next time the system tries it, it'll go through.
The time it takes for a throttle to clear changes dynamically based on Mudlet's calculation of network lag, using the built-in function getNetworkLatency()
. The module tries to enforce a minimum throttle time of 0.2 seconds and a max of 0.75 seconds, both of which can be easily changed in the script.
How To Use Throttling
All of the utility you need is in the attempt()
function. In breakdown:
→ attempt(action ID, command/function[, args...])
- action ID: This is a name you give to the action. This ID is the heart of the throttling system - all the function is doing is making sure there isn't already an action stored with the same ID.
- command/function: This is the actual command or code you want to go through. It accepts two formats: either a string, which will be sent to the game ("kick bandit", "absorb ylem", "quickmount" stacked 400 times, etc.), or a function. If invoking function, then...
- args...: Any arguments you would pass to the function. Examples below.
Examples:attempt("bash", "staffcast lightning at " .. getTarget())
A simple example. Executes an action with the ID "bash", to attack the target.if ylemMistInRoom then
attempt("bash", "absorb ylem")
attempt("bash", "combo " .. getTarget() .. " sdk ucp ucp")
Since both ylem absorption and Tekura combos require BAL/EQ, by giving their actions the same ID, we can avoid them interrupting or cross-talking with one another.attempt("check credits", sendAll, "credit report", "credits for sale")
An example of how to invoke a function using attempt(). Notice that sendAll is written without a string, and without its parentheses (we don't want to call and therefore evaluate it). Its arguments are listed with commas right after it, and we can specify any number of them that we want.