Network (rnet)
Rules
Block, drop, delay, change and duplicate packets without writing a handler.
A rule applies to packets automatically. Every function here returns a rule object.
Rule objects
| Method | Meaning |
|---|---|
rule:Remove() | Deletes the rule. Alias: rule:Destroy() |
rule:Pause() | Turns it off without deleting it |
rule:Resume() | Turns it back on |
rule:Toggle(on) | true resumes, false pauses |
rule.id is its numeric ID.
rnet.block(pattern = "*", dir)
Blocks matching packets completely. Passing (dir, pattern) in the old order also works.
local r = rnet.block("swing", "out")
task.wait(5)
r:Remove()
rnet.drop(pattern = "*", chance = 0.5, dir)
Drops matching packets at random. chance is from 0 to 1.
rnet.delay(pattern = "*", ms = 100, jitter = 0, dir)
Delays matching packets by ms milliseconds, plus or minus up to jitter.
rnet.lag(ms = 200, jitter = 0, dir = "out")
Delays everything in that direction. A quick way to fake lag.
rnet.set(pattern, field, value, dir, opts)
Sets a field on matching packets. opts can contain chance (0 to 1) and limit (stop after this many packets).
rnet.set("move_player_*", "onGround", true, "out")
rnet.setfield(dir, pattern, field, value)
The old argument order of rnet.set.
rnet.dup(pattern, times = 1, dir = "out")
Sends matching packets times extra times.
rnet.rule(cfg)
Creates a rule from a configuration table. The other functions here build it for you. The action can be "block", "drop", "delay", "set", "dup" or "hold", with the fields used above (match, dir, chance, ms, jitter, field, value, times, limit).
rnet.unrule(rule)
Removes a rule (the object or its ID).
rnet.rules()
Returns the list of active rules.
rnet.clearRules()
Removes every rule. Alias: rnet.clear().
rnet.blink(maxSeconds = 5)
Holds back everything you send until you release it or maxSeconds pass. Returns a table:
| Member | Meaning |
|---|---|
Release() | Sends everything held and stops blinking |
Active() | Whether it is still holding |
local b = rnet.blink(3)
task.wait(2)
b.Release()
rnet.flush(dir)
Sends every packet that is currently held in that direction.