Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Reload plugin alias
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Thu 23 Jul 2009 08:01 AM (UTC) Amended on Wed 31 Aug 2011 06:48 AM (UTC) by Nick Gammon
|
Message
| I was just browsing some other forums with references to MUSHclient, and I was very impressed with the level of support provided for MUSHclient there. :-)
Anyway, a question was asked about how to quickly reload a plugin after testing. I know I had an alias to do just that, but can't find it myself on this forum, so probably no-one else can either. :(
This is what I use when testing a new plugin:
<aliases>
<alias
match="rl"
enabled="y"
send_to="12"
sequence="100"
>
<send>
local plugin_id = "0abe0dab0170ede5f1ea0650"
local plugin_file = "/Program Files/MUSHclient/worlds/plugins/PLUGIN_NAME_HERE.xml"
local status = ReloadPlugin (plugin_id)
if status == error_code.eBadParameter then
Note ("Cannot reload ourself.")
elseif status == error_code.eNoSuchPlugin then
check (LoadPlugin (plugin_file))
end
if GetPluginInfo (plugin_id, 1) then
Note (GetPluginInfo (plugin_id, 1) .. " reloaded.")
end -- if have it now
</send>
</alias>
</aliases>
Basically this tries to reload the plugin (with ReloadPlugin) - this reloads an existing plugin, thus letting you test changes. However if the reason you are reloading is a syntax error in the plugin, then it won't exist in the first place, so as a fallback it calls LoadPlugin to load the plugin back in from disk.
So, for your own plugins you need to change two things:
- The plugin ID (this is from the line id="0abe0dab0170ede5f1ea0650" in the plugin header)
- The actual file name of the plugin, whatever that is.
Once you have done this, just type "rl" to reload the plugin and test your changes.
Thanks to Zarquan, Isuka, Esano and everyone else who is working hard to support MUSHclient on other forums. :)
[EDIT] Modified 31 August 2011 to test for a plugin attempting to reload itself.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| WillFa
USA (525 posts) Bio
|
Date
| Reply #1 on Thu 23 Jul 2009 08:21 AM (UTC) |
Message
| |
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #2 on Thu 23 Jul 2009 09:56 AM (UTC) |
Message
| I can see a few ways to improve it - making the plugin ID an alias parameter, for instance, or even looking up the ID based on a plugin's name - but this is definitely a very useful alias for development :) |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Talryk
(3 posts) Bio
|
Date
| Reply #3 on Wed 31 Aug 2011 06:24 AM (UTC) |
Message
| Heya, sorry to necromance such an old topic.
I took a close look at this alias as well as the other one cited by WillFa, and they both work just fine as world aliases. However, is there any way to call the Reload/LoadPlugin() functions from -within- the function being reloaded? I included an alias to define one's own file path, but it seems that the function completes (it gives me a '<plugin> reloaded' note), but changes are never reflected.
The goal is to give the people I hand this plugin out to a way to easily update it when I commit changes to it via SVN, so if anyone has better ideas I'm also open to suggestions. | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #4 on Wed 31 Aug 2011 06:33 AM (UTC) |
Message
| I think in order to use them from within the plugin, you should use DoAfterSpecial. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 31 Aug 2011 06:48 AM (UTC) |
Message
| I modified the original post to check for a plugin reloading itself, which isn't allowed.
Meanwhile, as Fiendish says, doing the reload on a timer should work. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Talryk
(3 posts) Bio
|
Date
| Reply #6 on Wed 31 Aug 2011 07:38 AM (UTC) |
Message
| Bah... Now I can't figure out where to implement DoAfterSpecial, and whether to match it to the plugin id or the file path, or both. My alias is as follows:
<alias
match="overgrowth:install"
enabled="y"
send_to="12"
sequence="100"
>
<send>
local plugin_id = "a8f9186fe987788ee0e94168"
local plugin_file = GetVariable("filepath").."/OvergrowthA.xml"
local status = ReloadPlugin (plugin_id)
if status == error_code.eBadParameter then
Note ("Cannot reload ourself.")
elseif status == error_code.eNoSuchPlugin then
check (LoadPlugin (plugin_file))
end
if GetPluginInfo (plugin_id, 1) then
Note (GetPluginInfo (plugin_id, 1) .. " reloaded.")
end -- if have it now
DoAfterSpecial(1, 'ReloadPlugin("a8f9186fe987788ee0e94168")', sendto.script)
</send>
</alias>
I put it at the end since I couldn't decide where to place it, and I -do- see TRACE: Fired unlabelled timer after 1 second, but I'm still not seeing changes reflected. In my particular case, the "filepath" variable is "/Users/Joe" and the xml is located there. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #7 on Wed 31 Aug 2011 11:00 AM (UTC) |
Message
| Hmm. Perhaps our advice was a bit wrong.
DoAfterSpecial adds a timer *in the context of the current plugin*.
So you have only moved the same problem forwards a second.
There will be ways around it ... the trick is to find the simplest.
You could make a second plugin, whose only job is to reload your "main" one. Then put the reload alias in that (ie. plugin #2 reloads plugin #1). Then you don't even need the timer.
I think another way could be to use the Execute function. That shrugs off the current plugin, I think. So if the alias called Execute "alias2" and alias2 did the DoAfterSpecial, that might work, although I haven't tested it. Make sure you use the timer in this case though, or you remove the script from underneath the executing plugin. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Talryk
(3 posts) Bio
|
Date
| Reply #8 on Thu 01 Sep 2011 02:54 AM (UTC) |
Message
| While not my most preferred option, creating a separate plugin performs the task perfectly and is easy enough to implement. Thanks for the suggestion, Nick! | Top |
|
Posted by
| Ada
(20 posts) Bio
|
Date
| Reply #9 on Sat 03 Sep 2011 01:20 PM (UTC) |
Message
| Hi! I just read this post and figured I'd chip in too! Here's the alias I use to reload plugins. Just hit 'replug <pluginname>' and it shall be done! It is case insensitive as well.
<aliases>
<alias
name="RePlug"
match="^replug (.+)$"
enabled="y"
group="Plugins"
regexp="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>local pluginname = string.lower("%1")
local plugins = GetPluginList()
for k, v in ipairs(plugins) do
if string.lower(GetPluginInfo(v, 1)) == pluginname then
ReloadPlugin(v)
end
end</send>
</alias>
</aliases>
| 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.
35,188 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top