Pretty plugins' functions calling
#1
Rainbow 
This code will help to call functions of other plugins, like they're just libraries:
PF={}
local function hasPlugin(name)
 return cPluginManager:DoWithPlugin(name,function(Plugin)
   if Plugin:IsLoaded() then
     return true
   end
   return false
 end)
end
setmetatable(PF,{
 __index=function(s,i)
   if not hasPlugin(i) then
     return nil
   end
   local pluginName=i
   return setmetatable({},{
     __index=function(s,i)
       return function(...)
         cPluginManager:CallPlugin(pluginName,i,...)
       end
     end
   })
 end
})
After adding this file in start of main file, all you need to call functions from other plugins is to call PF.PluginName.FunctionName(...), for example if you need to call a function named "CoolFunction" from plugin named "CoolPlugin", you can do this:
Code:
PF.CoolPlugin.CoolFunction(...)
Reply
Thanks given by:


Messages In This Thread
Pretty plugins' functions calling - by TC1061 - 01-13-2018, 03:46 PM
RE: Pretty plugins' functions calling - by xoft - 01-14-2018, 09:12 AM
RE: Pretty plugins' functions calling - by TC1061 - 01-15-2018, 03:07 AM
RE: Pretty plugins' functions calling - by xoft - 01-15-2018, 01:19 PM
RE: Pretty plugins' functions calling - by TC1061 - 01-15-2018, 01:45 PM



Users browsing this thread: 1 Guest(s)