core-utils is a utility library for OPM
The Player class represents a player in the world
player.id
The ID of the playerplayer.x
X position of playerplayer.y
Y position of playerplayer.rgb
An array in the format [R, G, B] representing the current color the player is usingplayer.tool
The id of the tool the player is usingplayer.nick
The nickname of the player, null
if unknownconst players = OPM.require("core-utils").players;
players.list
A map of all players where the key is their ID, and the value is a Player classplayers.on("join", (player) => {})
Emitted when a player joinsplayers.on("leave", (player) => {})
Emitted when a player leavesconst chat = OPM.require("core-utils").chat;
chat.commands
A map of locally registered commandschat.registerCommand(name, callback)
Used to register a local command with the name name
, the callback
receives the arguments as one arraychat.deregisterCommand(name)
Used to deregister and remove a local commandchat.on("message", (msg) => {})
Emitted when a chat message is received. msg
is either one of:
{
type: "user",
id: string,
message: string
}
{
type: "user",
id: string,
nick: string,
message: string
}
{
type: "moderator",
nick: string,
message: string
}
{
type: "admin",
nick: string,
message: string
}
{
type: "discord",
nick: string,
message: string
}
{
type: "dm",
from: string,
message: string
}
{
type: "server",
message: string
}