This repository has been archived by the owner on Mar 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Command
Karthlan edited this page Aug 4, 2012
·
2 revisions
Command is a lua class assisting in creating new player commands.
- Command:New(Command name) – Used to create a new instance.
- self:register() – Used to register the command.
- self.handler(event) – Override to set callback for the command.
- self.words – The word used for calling the function.
- self.groups – The groups allowed to use the command, use "All" to let all groups use the command and use group names in an array to let certain groups use the command. Ex. {"Gamemaster", "Senior Gamemaster"}.
- event.player – The player who called the command.
- event.param – The parameter passed in the command. Ex. /goto Azlan.
A command that creates a new monster
local CreateMonster = Command:new("CreateMonster")
CreateMonster.words = "/m"
CreateMonster.groups = {"Gamemaster", "Senior Gamemaster", "Community Manager", "Server Administrator"}
function CreateMonster.handler(event)
local name = event.param:strip_whitespace()
local monster = createMonster(name, event.creature:getPosition())
if not monster then
sendMagicEffect(event.creature:getPosition(), MAGIC_EFFECT_POFF)
event.creature:sendNote("Could not summon monster '" .. name .. "'.");
end
end
CreateMonster:register()