06-14-2012, 01:50 AM
Quote:The old plugins are ones that are set in the settings.ini by Plugin=<name>, rather than NewPlugin=<name>. They have a completely different architecture, from what I can gather.O, RLY?)
Take a look at the Area plugin. It's an old-style plugin:
Code:
-- create new unique global
AreaPlugin = {}
AreaPlugin.__index = AreaPlugin
-- some configurations
AreaPlugin.PLUGIN_NAME = "Area Plugin"
AreaPlugin.PLUGIN_VERSION = 3
AreaPlugin.PLUGIN_MSG_PREFIX = cChatColor.LightBlue .. "* "
-- some plugin locals
AreaPlugin.Players = {}
AreaPlugin.PlayerIdx = 0
Get rid of that part:
Code:
function AreaPlugin:new()
local t = {}
setmetatable(t, AreaPlugin)
local w = Lua__cPlugin:new()
tolua.setpeer(w, t)
w:tolua__set_instance(w)
return w
end
Code:
function AreaPlugin:OnDisable()
-- write back file
AreaPlugin.IniFile:WriteFile()
Log( self:GetName() .. " v." .. self:GetVersion() .. " is shutting down..." )
end
Code:
function OnDisable()
-- write back file
AreaPlugin.IniFile:WriteFile()
Log( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
end
Code:
-- create new instance of plugin
cRoot:Get():GetPluginManager():AddPlugin( AreaPlugin:new() )
TADA! Now you have new-styled Area plugin.
Quote:I don't even think all the new hooks work in them.Fair point. But when old-style plugins were written those hooks didn't even exist.
Of course, if plugin is REALLY old and don't have command bindings (it parses chat messages manually) you might want to update it to use commands (so commands would be visible with /help core plugin command!). But that's not requied for plugin to work.