Module eventlog

Event Log

Functionality to display a list of game events in the top-right corner.

Event log messages are posted on the server and then broadcasted to all players.

The items used to construct a message is designed to allow mods to express a wide variety of events. By calling eventlogTick(..) player death events will automatically be posted.

The client-side of the script will only need to call eventlogDraw(..).

-- Example that uses all of the eventlog functions.
function server.tick(dt)
    eventlogTick(dt)

    -- mod/game mode stuff

    if somethingNoteworthy then
        -- Posted events will be shared with all players.
        eventlogPostMessage({playerId, "did something cool!"}, 5.0)
        somethingNoteworthy = false
    end
end

function client.draw(dt)
    -- Draw the events client-side.
    eventlogDraw(dt)
end

Functions

eventlogPostMessage (items, time) Post a message to the event log (server).
eventlogTick (dt) Tick the event log (server).
eventlogDraw (dt[, playerColors]) Draw event log notifications on screen (client).


Functions

eventlogPostMessage (items, time)
Post a message to the event log (server).

Constructs a message for the eventlog from items and broadcasts the message to all players.

Parameters:

  • items table A list of "items" to put together in the message (in order).
  • time number The duration that the message should last (in seconds).

    An item can have:

     text (string): Text to display on the item
     textColor (table): color of the text. The table can have 3 numbers: {r, g, b}
     color (table): Background color of the item. The table can have 3 numbers: {r, g, b}
     icon (string): Path to icon image
     iconTint (table): Color tint of the icon
     playerId (number): Player ID associated with the item. Used to automatically
         determine other properties like the background color and icon.
         Also highlights the text in yellow when the ID matches the client
     iconRight (boolean): Moves the icon to be positioned on the right of the text
    

    An item can also be automatically converted to a table from: * a string. automatically converted to a table in the form: {text = x} * a number. automatically converted to a table in the form: {playerId = x}

eventlogTick (dt)
Tick the event log (server).

Detects playerdied events and posts a relevant message.

Parameters:

  • dt number Time step
eventlogDraw (dt[, playerColors])
Draw event log notifications on screen (client).

The playerColors table is used to set the color of an item in a message, that is related to a specific player.

Parameters:

  • dt number Delta time used to decrement messages display time.
  • playerColors table A table that maps playerId to color {r,g,b}. (optional)
generated by LDoc 1.5.0 Last updated 2025-12-09 10:41:23