[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  PluginIDs
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

PluginIDs

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Thu 25 Dec 2008 07:07 AM (UTC)

Amended on Thu 25 Dec 2008 07:13 AM (UTC) by WillFa

Message
I'm writing a plugin whose design kinda evolved after noticing LoadPlugin()

The thing I'm noticing is that all the other Plugin functions want a PluginID, and GetPluginID accepts no parameters returning only the current plugin's ID. Is there an easy, direct way to get this for another plugin?

For Example:
PluginA calls LoadPlugin("C:\foo.xml")

How can PluginA get foo.xml's pluginID?

I've thought of the addxml module and parsing the file to get the id entity, or since PluginA uses SQLite, having a temp table that's GetPluginList() before calling LoadPlugin, and GetPluginList() a second time, and using SELECT * from b where id not in(select * from a)... (or a couple of for loops to invert key/value for the first, and if not knownPlugins[k] then heresMyNewId = k ; break )

Am I over thinking the problem? Is there an easy way to get another plugin's id from a file path?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 25 Dec 2008 09:05 AM (UTC)
Message
Quote:

Is there an easy, direct way to get this for another plugin?


Another plugin you just loaded?

I suppose the simplest thing would be to call GetPluginList before loading the plugin, turn that into a table keyed by ID (rather than number), call it again after loading the plugin, and then call GetPluginList again. For each entry check if it was already in the previous list (by a simple keyed lookup). If not, that must be the new ID.

Another approach which would be fairly simple would be to read the first few hundred bytes of the plugin file, and with a fairly simple regexp find the id="<whatever>" line.

You could also utils.xmlread as you suggested. It might be a bit of an overkill when the regexp would probably be 99.9% reliable.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 25 Dec 2008 09:07 AM (UTC)
Message
I suppose you have seen this thread?

http://www.gammon.com.au/forum/?id=8767

Loading heaps of plugins can be tedious, and that plugin solved it by simply loading all the plugins it finds in a subdirectory.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #3 on Thu 25 Dec 2008 02:24 PM (UTC)
Message
Over-thought the problem.

Since "Foo.xml" is specifically made to be within the framework of PluginA, Foo can
BroadcastPlugin(n, GetPluginInfo(GetPluginInfo(), 6)) during its OnPluginInstall.

n is arbitrarily decided.

PluginA has an OnPluginBroadcast(msgnum, id, name, txt) function to trap it.


Basically, PluginA shouldn't look it up, Foo should announce it.


[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,648 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]