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
➜ General
➜ 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 page
Posted by
| Blainer
(191 posts) 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) 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?
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Blainer
(191 posts) 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? | Top |
|
Posted by
| Blainer
(191 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) 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 | Top |
|
Posted by
| Twisol
USA (2,257 posts) 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 | Top |
|
Posted by
| Fiendish
USA (2,535 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) 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 | 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.
25,788 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top