This repository was archived by the owner on Sep 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Zachary Mayhew edited this page Jan 8, 2016
·
3 revisions
Welcome to the LuaBlocks wiki!
To make a lua plugin, first start up the server with LuaBlocks installed. This will initialize the plugins directory. After doing so, open up <server directory>/plugins/LuaBlocks/plugins. In that directory, create a file called myplugin.lua in that directory.
In your plugin lua file, type the following:
require 'io.github.zacklukem.bukkit.bukkit'
myplugin = {}
-- This function is called when the plugin is enabled.
-- Here you put your basic startup code
function myplugin.onEnable ()
bukkit.logger.info("My Plugin onEnable")
end
-- This is called when the plugin is disabled.
-- Here you put your basic shutdown code
function myplugin.onDisable()
bukkit.logger.info("My Plugin onDisable")
endCommands are simple to use. Just create a function called myplugin.onCommand and register a command
require 'io.github.zacklukem.bukkit.bukkit'
-- To use commands, this must be imported
require 'io.github.zacklukem.bukkit.command'
myplugin = {}
function myplugin.onEnable ()
bukkit.logger.info("My Plugin onEnable")
-- You must register the command to make your oncommand function execute.
command.registerCommand("myplugin", "mycommand")
end
function myplugin.onDisable ()
bukkit.logger.info("My Plugin onDisable")
end
function myplugin.onCommand (sender, label, args)
if label == "mycommand" then
-- args start at index 1, not index 0
sender.sendMessage("Hello, " .. args[1])
return true
end
return false
end