on = {
monster_killed = function(m, ev)
if ev.killer then rf.notice(ev.killer.id, "Nice kill: " .. ev.monster.name) end
end,
},
An event is a notification: the thing has already happened, and the game never waits for a module. Each module has one worker that runs its events, timers, commands and messages one at a time, in order. A full queue (lua.event_queue) drops new events and counts them in %mod status.
An event is a snapshot. By the time a handler runs, the player may have logged out, so an action can fail. Running Modules shows how to catch that.
Notes on Particular Events
chatfires only for a line really sent. A line refused for any reason, by a chat gate or by the game, raises no event.monster_spawnedfires for every spawn and respawn while modules run. The server's first placement happens before they start.player_commandfires when a player types the prefix and a word no module declared as a command. Subscribe only if you mean to: while any module listens to it, every chat line starting with the prefix is consumed, declared command or not.messageis the event form of a declared message arriving.
Event Reference
auction_listed
An item was listed on the auction.
| field | type | notes |
|---|---|---|
player | player | the seller |
item | item | what |
price | number | asking price |
currency | string | the price's currency |
chat
A chat line was sent.
| field | type | notes |
|---|---|---|
player | player | who |
channel | string | circle, race, map, raceboss, racebosscry, guild, whisper, all or greeting |
text | string | the line |
target | string or nil | the whisper target's name |
chipwar_end
The Chip War closed.
No fields.
chipwar_result
The Chip War was decided.
| field | type | notes |
|---|---|---|
winner | string | the winning race, or "" for none |
reason | string | how it was decided: stone_destroyed, time_up, keeper_destroyed or keeper_kept |
chipwar_start
The Chip War opened.
No fields.
item_dropped
An item landed on the ground.
| field | type | notes |
|---|---|---|
item | item | what |
source | string | "monster" or "player" |
monster | monster or nil | the monster that dropped it |
player | player or nil | the thrower, or the loot owner |
map | string | map name |
pos | pos | where |
box | number or nil | the ground box, for rf.pickup; nil on a server without it |
item_looted
A player picked an item up.
| field | type | notes |
|---|---|---|
player | player | who |
item | item | what |
map | string | map name |
level_up
A character gained a level.
| field | type | notes |
|---|---|---|
player | player | who |
from | number | previous level |
to | number | new level |
login
A character entered the world.
| field | type | notes |
|---|---|---|
player | player | who |
first | bool | true on the character's first ever entry |
logout
A character left the world.
| field | type | notes |
|---|---|---|
player | player | who |
message
A player's client sent one of this module's declared messages.
| field | type | notes |
|---|---|---|
player | player | who |
message | string | the declared message name |
fields | table | the decoded fields |
monster_killed
A monster died.
| field | type | notes |
|---|---|---|
monster | monster | what |
killer | player or nil | the credited player, nil when none |
map | string | map name |
pos | pos | where |
monster_spawned
A monster entered the world.
| field | type | notes |
|---|---|---|
monster | monster | what |
map | string | map name |
pos | pos | where |
player_command
A player typed a module command after the player prefix.
| field | type | notes |
|---|---|---|
player | player | who |
command | string | the command name |
args | string | the rest of the line |
pvp_kill
A player was killed by another player.
| field | type | notes |
|---|---|---|
killer | player | the credited player |
victim | player | who died |
map | string | map name |
pos | pos | where |
upgrade
An enhance or upgrade attempt finished.
| field | type | notes |
|---|---|---|
player | player | who |
item | item | the item |
success | bool | whether it took |
level | number | the item's upgrade level now |
Payload Tables
| table | fields |
|---|---|
| player | account, class, guild, id, level, map, name, race, staff |
| monster | code, name, serial |
| item | code, count, name, uid |
| pos | x, y, z |