board
The bulletin boards: items whose template has the script bulletin_board, each with its own messages. A script opens one on a player, posts on it in any name, lists its messages and removes one. The module does not check who calls it nor how far anyone stands: the item script's on_use already asks for two tiles and sight, and a script for the staff checks world.is_staff first.
Source: src/Moongate.Server.Ultima/Modules/BoardModule.cs
Functions
Section titled “Functions”messages
Section titled “messages”board.messages(board) -> tableThe messages of the bulletin board as an array of { serial, thread, poster, name, subject, lines, posted_at }: the threads from the oldest, each followed by its replies in the order they were posted. thread is the serial of the first message of the thread a reply is under, nil on a first message. poster is the serial of the character who posted, nil for a message a script posted; name is the name it posted under. lines is an array of strings. posted_at is in seconds, as world.now(). An empty array for a board with no message and for what is not a board.
What is on a board, thread by thread:
for _, message in ipairs(board.messages(notice_board)) do local kind = message.thread and " reply" or "thread"
log.info(kind .. " by " .. message.name .. ": " .. message.subject .. " (" .. #message.lines .. " lines)")end| Parameter | Type | Default |
|---|---|---|
board | integer |
Returns table.
board.open(board, player) -> booleanOpens the bulletin board on the player's client: the threads that are over go first, then the client shows the board and lists its messages, and asks for each as the player reads. From then on the player reads, posts, replies and removes its own messages while it stays within two tiles of the board. False when the item is not a bulletin board, or the player is not in the world with a client.
The item script of a bulletin board: a double click opens it on the player.
function bulletin_board.on_use(serial, user) board.open(serial, user)
return trueend| Parameter | Type | Default |
|---|---|---|
board | integer | |
player | integer |
Returns boolean.
board.post(board, name, subject, lines, thread?) -> integer?Posts a message on the bulletin board in the name given and gives its serial; nil when nothing was posted: the item is not a bulletin board, the name, the subject or every line is empty, no serial was ready (the same call works a moment later), or thread is not a serial at all. lines is an array of strings, one per line of the message; a number among them is written as text, anything else is left out, and the lines end at the first nil, as ipairs does. With thread, the serial of a message of that board, it is a reply and goes under the first message of that thread; a thread that is gone or of another board makes it a new thread. No character is the poster: the post does not wait, shows a bare body beside the text, and only the staff can remove it from the board's window. The name is cut at 30 characters, the subject at 60, a line at 80 and the message at 32 lines; a board beyond ultima.bulletin_boards.max_messages lets its oldest thread go. A player with the board open sees the post when it opens the board again.
A town crier leaves a notice on the board beside it, then answers under it:
local notice = board.post(notice_board, "The town crier", "Hear ye", { "The bank of Britain is closed today.", "", "Come back tomorrow."})
if notice then board.post(notice_board, "The town crier", "Re: Hear ye", { "It is open again." }, notice)end| Parameter | Type | Default |
|---|---|---|
board | integer | |
name | string | |
subject | string | |
lines | table | |
thread (optional) | integer | 0 |
Returns integer?.
remove
Section titled “remove”board.remove(message) -> booleanRemoves the message with that serial from its bulletin board, and its replies with it when it is the first message of a thread; false when there is no such message. It asks nobody: a script that removes for a player checks first that the message is the player's, with the poster of board.messages.
A staff script clears what a script posted more than a day ago:
for _, message in ipairs(board.messages(notice_board)) do if not message.poster and world.now() - message.posted_at > 86400 then board.remove(message.serial) endend| Parameter | Type | Default |
|---|---|---|
message | integer |
Returns boolean.
Made with ❤️ by Tom
