Lib or Plugin

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Lib or Plugin

Postby decompile » Thu Mar 23, 2017 3:02 am

Hey,

Im planning on making a plugin which detects players who are afk, and make it useable for my other plugins.
The question is, does it need to be a custom package/module or a plugin itself, if so, how can I import a plugin like in es?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Lib or Plugin

Postby satoon101 » Thu Mar 23, 2017 3:14 am

It doesn't "have" to be a custom package, but it might be easier for it to be one. I have been sorely needing an AFK detector for GunGame and have not gotten around to making one myself. So, if you do make one, I might end up using it.

If you go the other route, you can use something like the following:

Syntax: Select all

from plugins.manager import plugin_manager

other_plugin_name = '<other_plugin_name>'
plugin_instance = plugin_manager.get_plugin_instance(other_plugin_name)
if plugin_instance is None:
raise LookupError(
'Plugin {other_plugin_name} is not loaded!'.format(
other_plugin_name=other_plugin_name,
)
)

I would use something like that to make sure it is loaded, but after that, you can import it like you would anything else.

Syntax: Select all

from other_plugin.other_plugin import some_object

But, again, it would probably be much easier if it was just a package if all it is supposed to do is detect AFKs.

Eventually, once the SP Project Manager is complete, there will be a way of marking required custom packages so that they will be installed/updated on "sp install/update" (once those commands are created).
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Bing [Bot] and 43 guests