class Log: Component

A component that stores a queue of recent log messages.

messages: Queue

A basic FIFO (First In, First Out) queue implementation.

messageLimit: integer
__new(self: Log, size?: integer)

Initializes a new Log component instance.

Parameters:

size? (integer) – An optional size limit for the log. Defaults to 32. Oldest messages are removed first.

iterLast(self: Log, n: integer): (iterator?: fun(): string)

Returns an iterator over the last n log messages, most recent first.

Parameters:

n (integer) – The maximum number of messages to return.

Returns:

iterator? (fun(): string) – A function that returns each log message or nil when done.

staticmethod addMessage(actor: Actor, message: string, ...: any)

Adds a message to an actor’s log component, if it exists.

Parameters:
  • actor (Actor) – The actor.

  • message (string) – The message, optionally with string.format characters.

  • ... (any) – Additional parameters passed to message:format().

staticmethod addMessageSensed(level: Level, action: Action, message: string, ...: any)

Adds a message to all actors who sensed the source actor at the time the message was generated.

Parameters:
  • level (Level) – The level.

  • action (Action) – The action.

  • message (string) – The message, optionally with string.format characters.

  • ... (any) – Additional parameters passed to message:format().