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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Reload a plugin from within a plugin.

Reload a plugin from within a plugin.

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


Posted by Blainer   (191 posts)  [Biography] bio
Date Fri 20 Nov 2009 06:29 AM (UTC)
Message
I'm trying to make a function to clear all variables in a plugin then reload the plugin.

In the help file for ReloadPlugin() it mentions DoAfterSpecial(). I've tried this but it didn't work.

Any suggestions?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 20 Nov 2009 07:13 PM (UTC)
Message
In what way does it not work? And why do you want to do it?

Template:post=9615 Please see the forum thread: http://gammon.com.au/forum/?id=9615.

- Nick Gammon

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

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #2 on Fri 20 Nov 2009 10:16 PM (UTC)
Message
I want the alias to be from within the plugin not on the world file.

DoAfterSpecial (1, "ReloadPlugin(GetPluginID())", 12)

It just does nothing and the error from check is Bad Parameter.

Does the plugin need to remove itself just after this DoAfter? If so how?
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #3 on Fri 20 Nov 2009 10:39 PM (UTC)
Message
I had a thought I could achieve this with a single variable that makes the plugin do everything as though it was a first time install. That would remove all old info. I would need a little note to the user on re-installing the plugin from the plugins dialog but it would only be when the plugin had a repeating error because it was saving and loading bad info this happens when I change the plugin a lot then load it into a world with an old state file. But it makes me want an easy way to fix up with out needing to open a file manager.

Any ideas would be welcome.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sat 21 Nov 2009 12:15 AM (UTC)

Amended on Sat 21 Nov 2009 01:16 AM (UTC) by Nick Gammon

Message
Ah, yes, the DoAfterSpecial just defers for one second something it can't do now, to something it can't do a second later. :)

I note the help says "use something like DoAfterSpecial". Maybe some different approach? You need to somehow reload the plugin in global script space, not plugin script space. A running plugin can hardly reload itself.

However I would suggest fixing your problem a different way. For example, since Lua keeps everything in tables, just re-initialize the tables, rather than reloading the plugin.

- Nick Gammon

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

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #5 on Sat 21 Nov 2009 12:32 AM (UTC)

Amended on Tue 05 Dec 2017 07:18 PM (UTC) by Fiendish

Message

local action = "DoAfterSpecial(1, ReloadPlugin([[" .. GetPluginID() .. "]]), 12)"

local prefix = GetAlphaOption("script_prefix")
if prefix == "" then
  SetAlphaOption("script_prefix", "/")
  Execute("/" .. action)
  SetAlphaOption("script_prefix", "")
else
  Execute(prefix .. action)
end


I think that would work. I do think you could accomplish your goals in a better way, though, as Nick mentioned.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #6 on Tue 05 Dec 2017 07:21 PM (UTC)

Amended on Tue 05 Dec 2017 08:12 PM (UTC) by Fiendish

Message
Twisol said:


local action = "DoAfterSpecial(1, ReloadPlugin('" .. GetPluginID() .. "'), 12)"

local prefix = GetAlphaOption("script_prefix")
if prefix == "" then
  SetAlphaOption("script_prefix", "/")
  Execute("/" .. action)
  SetAlphaOption("script_prefix", "")
else
  Execute(prefix .. action)
end


I think that would work.


Note of warning: This crashes MUSHclient for me initiating it from the input bar with CallPlugin even if I put the Executes in their own DoAfterSpecials. I don't understand why.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Tue 05 Dec 2017 09:51 PM (UTC)

Amended on Tue 05 Dec 2017 09:53 PM (UTC) by Nick Gammon

Message
It is because the function call ReloadPlugin is done now, not after one second:


local action = "DoAfterSpecial(1, ReloadPlugin([[" .. GetPluginID() .. "]]), 12)"
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


You need to quote it:


local action = "DoAfterSpecial(1, 'ReloadPlugin([[" .. GetPluginID() .. "]])', sendto.script)"
                                  ^                                         ^


Now that says, after one second execute the script command (the thing in quotes).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


22,146 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 HostDash]