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.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Setting a "global" MUSHclient variable
Setting a "global" MUSHclient variable
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Chyort
USA (58 posts) Bio
|
Date
| Mon 23 Mar 2015 06:47 AM (UTC) Amended on Mon 23 Mar 2015 07:10 AM (UTC) by Chyort
|
Message
| From GetPluginVariable
If you are writing a plugin and want to find a "global" MUSHclient variable value, use an empty plugin ID, eg.
world.Note world.GetPluginVariable ("", "target")
I am just wondering, is there any simple way to set a "global" MUSHclient variable from inside a plugin?
I can pull the info with GetPluginVariable, but i can't find any way to set it.
Searching the forums i have found a lot about serializing tables, but that is way more than i need. And I'm not entirely sure if it would save it in "global", or the plugin's save state file.
I ask because i would like to allow some stupidly simple plugins to store/share simple variables in the world file itself. Instead of the 150+ plugin state files i currently have.
Thanks for any help you can give me.
*Edit* I understand not wanting plugins to interfere with each other, but nothing i do will be distributed, so it isn't an issue for me. And for my personal use, some interaction would be helpful.
PS, Your GetPluginVariable Lua example has a mistake.
MyName = GetPluginVariable ("a42fbf74f394d8129df956ae", "MyName")
if MyName == nil then
Note("MyName is not defined")
else
note(MyName)
end
| Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #1 on Tue 24 Mar 2015 03:36 AM (UTC) Amended on Tue 24 Mar 2015 03:48 AM (UTC) by Fiendish
|
Message
| I too have legitimate (I think) desires for (in my case write-only) changes to the global space that can't work without this. As far as I know there isn't a way short of injecting text into the world file with system file IO and then reloading the world. I haven't tried that, so there may be complications, but it's the closest you'll get.
Quote: *Edit* I understand not wanting plugins to interfere with each other
That doesn't mean they should be banned from making changes in the world space. It's not like plugins can set variables inside of other plugins. If a plugin author needs to avoid conflict, the plugin's variable space should be used. But there's a world space for a reason. I think it should be shared and plugins should be able to change it. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #2 on Tue 24 Mar 2015 08:59 PM (UTC) |
Message
|
Quote:
PS, Your GetPluginVariable Lua example has a mistake.
Fixed.
The standard way of doing this is by using an alias in the main world space to "catch" a plugin that does a "send to execute".
I seem to remember Twisol had a fancy way of achieving that as well. I'll try to find it. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #3 on Tue 24 Mar 2015 09:07 PM (UTC) |
Message
| I think Twisol's method was to use CallPlugin to call "SetVariable" in another plugin, however this doesn't solve your problem for the main world space.
What it might help with, is if you put your shared variables into a "variable holding" plugin. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #4 on Wed 25 Mar 2015 05:34 AM (UTC) Amended on Wed 25 Mar 2015 05:41 AM (UTC) by Fiendish
|
Message
| That makes it hard for non-programmer users to see and modify stored elements. The only reason for wanting to use public space is access via the standard interface instead of a plugin-specific one. Otherwise you have scenarios where a plugin that has no visible presence must necessarily have non-visibly-discoverable commands also for viewing and modifying the storage. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 25 Mar 2015 08:47 AM (UTC) |
Message
|
Quote:
Otherwise you have scenarios where a plugin that has no visible presence must necessarily have non-visibly-discoverable commands also for viewing and modifying the storage.
I'm not totally certain what you mean by that. The decision to not allow plugins to modify each others' variables (or the global variables) is consistent with operating systems not allowing separate apps from interfering with each other. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #6 on Wed 25 Mar 2015 06:20 PM (UTC) |
Message
|
Nick Gammon said:
Quote:
Otherwise you have scenarios where a plugin that has no visible presence must necessarily have non-visibly-discoverable commands also for viewing and modifying the storage.
I'm not totally certain what you mean by that.
If your plugin doesn't display anything to the screen, then it doesn't have anything to look at or click on. If it doesn't have anything to look at or click on, then the command aliases contained by the plugin must be invisible to the user without code inspection. If you want the user to be able to look at and modify the plugin's storage without resorting to mucking about inside state files, you have to add commands that then construct interfaces for viewing and modifying the plugin's storage. Except how do you communicate to the user that such a command exists?
Quote:
The decision to not allow plugins to modify each others' variables (or the global variables) is consistent with operating systems not allowing separate apps from interfering with each other.
I'm not advocating that plugins be allowed to modify each other's variables, just the world's.
To make your analogy more accurate, the operating system doesn't prevent separate apps from reading and writing to the same files. Neither does MUSHclient. We already have shared spaces, albeit with a built-in IO performance hit, we just don't have a shared space that is inherently user discoverable.
I don't actually want multiple plugins to set the same things at all.
What I want is for users to know where to set them without additional instruction.
A better way would be a plugin variable explorer as part of the MUSHclient settings interface alongside the world variable explorer, but that just seems more difficult. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #7 on Wed 25 Mar 2015 08:31 PM (UTC) Amended on Wed 25 Mar 2015 08:33 PM (UTC) by Nick Gammon
|
Message
| OK, well since he just wants to allow all plugins to set world variables, my first suggestion will work. Make an alias like this:
<aliases>
<alias
match="^\+\+\+SetVariable (\w+) (.*)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("%1", "%2")</send>
</alias>
</aliases>
Then any plugin can "Execute" this alias which will alter a variable in global variable space. Like this:
Execute ("+++SetVariable " .. "foo" .. " " .. "contents of foo")
The space between the variable name and the contents is required. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Chyort
USA (58 posts) Bio
|
Date
| Reply #8 on Thu 26 Mar 2015 09:43 AM (UTC) |
Message
| Hah, this got a bit more traffic than i expected.
Thanks for the example Nick. I will have to poke and prod a bit but i think it will work for me.
The closest other example i could find was from back in 2008, and it was using GetPluginVariable from the world file to pull the variable out of the plugin. Which could/would have worked, but would have required more of a brute force approach for what i am trying to accomplish.
Fiendish said:
A better way would be a plugin variable explorer as part of the MUSHclient settings interface alongside the world variable explorer, but that just seems more difficult.
Assuming i have followed the rest of the conversation right.(Which i might well not have :P)
I can see some advantages to a full plugin editor/viewer that uses the same GUI that you get inside mush.
So when i edit a plugin from the plugin window instead of having the .xml open in notepad++ or whatever your chosen scripting editor is, it instead opened a Trigger/alias/timer/variable window just like regular triggers use.
Being a non-programmer, i have no idea how difficult that would be on your end Nick, But it would make minor edits, or viewing variables, or whatever else a lot simpler for us novices.
As it currently stands i normally just import the plugin into a blank worldfile so i can do my edits there, then copy/paste back into the .xml plugin. And i still have to use scripting, or dig through my 150+ odd save_state files to view the variables.
Anyways!... Thanks for the help with my original question. :) | 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.
24,184 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top