Home / Getting started

First plugin

Create plugins/Welcome.lua. The filename becomes the plugin name.

log("Welcome plugin loaded")

command("hello", {
  usage = "/hello",
  description = "Say hello"
}, function(sender)
  sender:send("Hello, " .. sender.name .. "!")
  return true
end)

on("join", function(event)
  event.player:send("Welcome to the server!")
end)

The command handler receives sender, a 1-based array of string arguments, and the lowercased command label/alias as its third argument when declared. Return false to show the usage text; returning true or no value counts as handled. The join event is informational.

When hot reload is enabled, saving the file loads or reloads the plugin automatically. Otherwise use /reload from the console or as an operator.

Plugin callbacks run on the server thread. Avoid blocking operations and large loops, as they can delay game ticks.