Why are plugins global?

Posted by ERogue on Mon 22 Feb 2016 03:51 AM — 4 posts, 15,704 views.

#0
Greetings. After a week or of using MUSHClient 5.01, I've made good progress learning, imo, but I still have a few basic issues (I think I'll only post one at a time, tho). Please accept my apologies if I've failed at searching. And upfront allow me to offer thanks for any support from anybody.

Firstly, I'd expect plugins to be local to a world rather than a global setting. A practical case is the AddNewLineToPrompt plugin to enable prompt triggers on servers that don't have newline in their prompt. Obviously, this is very frequently customized to each server, so having it global has little practical value as I use multiple worlds.

I can see that it could be extended to switch cases per connection (if I knew how), but regardless I'm just wondering if I'm overlooking something more direct.

Good evening.
Australia Forum Administrator #1
Plugins are intended to be useful files in their own right, and therefore loaded into multiple world files (and even given to friends so they can use them as well).

However a plugin is only "applied" to a particular file if you load it (using File menu -> Plugins).

There is a provision for global plugins in the File menu -> Global Preferences, but you would only use that for plugins that you happened to want in every world.

I'm not sure if that answers your question, but perhaps it does. Are you by any chance accidentally using the Global Plugins option rather than world-by-world plugins?
USA Global Moderator #2
Quote:
A practical case is the AddNewLineToPrompt plugin to enable prompt triggers on servers that don't have newline in their prompt. Obviously, this is very frequently customized to each server, so having it global has little practical value as I use multiple worlds.

The entire point of a plugin is that the code stays the same no matter what world you load it into. If this is a problem then you're customizing wrong. Plugin state is saved per world. If you have different worlds needing different effects but basically the same code, don't customize the code per world! Genericize the code to load the relevant parameters from variables so that the same code can run in any world with customized variable data.
Amended on Mon 22 Feb 2016 11:29 AM by Fiendish
#3
Nick Gammon said:

However a plugin is only "applied" to a particular file if you load it (using File menu -> Plugins).

There is a provision for global plugins in the File menu -> Global Preferences.


Oh, great, indeed I only saw the option for File menu / Global Preferences, I completely overlooked File menu / Plugins!

I was in fact missing the obvious, thanks!

[Edit to add:]
Resolved.

Testing is so much quicker now that I can just reload a world pluging rather than restarting the client.

For what it's worth, I assumed non-global plugins didn't exist because there's no plugin section in the World Properties screen. Perhaps such a section could be added.

Have fun.