Old School Ops

Gates

Refusing or changing an auction listing, a chat line, a pickup or a hit while it happens, and the budget a gate runs under.

Applies to RF Online 4.55RF Online 4.15RF Online 1.5RF Online 2.2.3.2 · updated 2026-11-06
On this page

A gate runs while the game waits, before the thing happens, and can refuse it or change it.

gates = {
  auction_list = { fail = "closed", run = function(m, ev)
    if ev.price > m:setting("max_price") then return false, "That price is too high." end
  end },
  damage = { fail = "open", run = function(m, ev)
    return { amount = math.floor(ev.amount / 2) }
  end },
},

What a Gate Returns

returnmeans
nil or truego ahead unchanged
false or false, "reason"refuse; the player sees the reason, and for damage the hit is cancelled
a number (damage) or a string (chat)go ahead with that amount or text
a table such as { text = "..." }go ahead with the named fields changed

A damage gate's answer is clamped between 0 and lua.damage_max_factor times the original hit.

A gate allows, refuses or changes the fields marked changeable, and nothing else. It cannot change who sees an auction listing, so a cross-race auction is not something a module can build.

When a Gate Cannot Answer

Every gate declares fail, and the load refuses one without it.

failwhen the module cannot answer
"open"the thing goes ahead
"closed"the thing is refused

That covers an error, running over budget, the module being busy, and the module being switched off after repeated errors. A module an operator switched off with %mod disable is skipped.

Fail closed when the gate protects the economy, such as an auction ceiling. Fail open when it only adds something, such as a chat filter.

Inside a Gate

A gate has a tight budget (lua.gate_budget_ms, and lua.damage_budget_ms for damage, which runs on every hit in the game). budget_ms on the gate asks for less.

  • Read the event and your module's own Lua tables. Do not loop over players.
  • A gate decides, and an on handler acts. Any verb that changes the world raises an error, and so does rf.monsters. rf.notice and the other queries work.
  • m:send and bag writes are applied just after the gate returns.
  • A bag read returns only what this module has already read or written, and may be empty. bag:keys() is unavailable.
  • Custom tables raise an error.

Keep what a gate needs in a top-level Lua table, filled by on_start, commands and handlers. examples/auction_max_price.lua and examples/pvp_penalty.lua both work that way.

At most lua.max_gates modules may gate one point. They run in module-name order, and the first refusal ends the chain.

The Damage Gate

ev.attacker is the attacking player. When the hit comes from something a player owns or commands, ev.source says what (animus, tower, trap, siege, unit, nuclear, potion or drain) and ev.attacker is its owner or master. ev.source is nil for a player's own swing, skill or force.

Gate Reference

auction_list

An item is about to be listed; return false, "reason" to refuse it.

Suggested fail: closed.

fieldtypenotes
playerplayerthe seller
itemitemwhat
pricenumberasking price
currencystringthe price's currency

chat

A chat line is about to be sent; return false to drop it or {text=s} to rewrite it.

Suggested fail: open.

fieldtypenotes
playerplayerwho
channelstringthe channel
textstring, changeablethe line
targetstring or nilthe whisper target's name

damage

A hit is about to land; return false to cancel or {amount=n} to change it.

Suggested fail: open.

fieldtypenotes
attackerplayer or nilthe attacking player
attacker_monstermonster or nilthe attacking monster
targetplayer or nilthe player being hit
target_monstermonster or nilthe monster being hit
amountnumber, changeabledamage about to be dealt
skillstring or nilskill or force code, nil for a plain attack
sourcestring or nilwhat dealt it when no player's swing did: animus, tower, trap, siege, unit, nuclear, potion or drain; the player behind it is attacker
criticalboolwhether the hit is critical
mapstringmap name

loot

A player is about to pick an item up; return false to refuse it.

Suggested fail: open.

fieldtypenotes
playerplayerwho
itemitemwhat
mapstringmap name
Something here wrong?

Out of date, incomplete, or assuming something it should not. Documentation errors are bugs, and this one arrives tagged and pointed at this page.

Top xp sources

How xp works
Loading…

Open the full search page