I wrote this small XML library to make it easier to write and maintain my structured plugins. One of the first things it does is "fix" the path and cpath to be relative to the structured plugin's directory rather than the plugins/ directory. It also creates a plugger.path() function to easily get a path relative to the plugin's directory.
The last thing it does is execute a require("scripts.main") call, seeking a main.lua file within the scripts/ subfolder. Coupled with a form of scripted trigger/alias/timer creation, such as direct MUSHclient API or my Reflex library, the only XML files you really need are this one and the plugin file itself.
I wrapped this library in XML to make it easy for a plugin author to package and include without going through too many contortions. I could have done raw Lua instead, but this isn't (and arguably shouldn't be) a standard-distribution library, so it's easier to package with the plugin itself than to require that it be installed separately into the MUSHclient/lua/ folder.
The last thing it does is execute a require("scripts.main") call, seeking a main.lua file within the scripts/ subfolder. Coupled with a form of scripted trigger/alias/timer creation, such as direct MUSHclient API or my Reflex library, the only XML files you really need are this one and the plugin file itself.
I wrapped this library in XML to make it easy for a plugin author to package and include without going through too many contortions. I could have done raw Lua instead, but this isn't (and arguably shouldn't be) a standard-distribution library, so it's easier to package with the plugin itself than to require that it be installed separately into the MUSHclient/lua/ folder.
<!DOCTYPE script>
<script><![CDATA[
plugger = {}
plugger.path = function(subdir)
if not subdir then
subdir = ""
else
subdir = subdir:gsub("%.", "\\")
if subdir:sub(#subdir) ~= "\\" then
subdir = subdir .. "\\"
end
end
return GetPluginInfo(GetPluginID(), 20) .. subdir
end
-- fix the lua path
do
local path = utils.split(package.path, ";")
path[1] = plugger.path() .. "?.lua"
table.insert(path, 2, plugger.path() .. "libraries\\?.lua")
table.insert(path, 3, plugger.path() .. "libraries\\?\\init.lua")
package.path = table.concat(path, ";")
local cpath = utils.split(package.cpath, ";")
cpath[1] = plugger.path() .. "?.dll"
table.insert(cpath, 2, plugger.path() .. "libraries\\?.dll")
package.cpath = table.concat(cpath, ";")
end
require("scripts.main")
]]></script>