Page 1 of 1

Lib or Plugin

Posted: Thu Mar 23, 2017 3:02 am
by decompile
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?

Re: Lib or Plugin

Posted: Thu Mar 23, 2017 3:14 am
by satoon101
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).