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
➜ How to set a plugin variable's value in another plugin?
How to set a plugin variable's value in another plugin?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Jcl
(42 posts) Bio
|
Date
| Sat 12 Nov 2005 07:21 AM (UTC) |
Message
| For example, I installed two plugins:
Plugin A has a variable named "skill".
In plugin B, now I can read it's value by world.GetPluginVariable(A, "skill"), but how can I change the value? Why not exist world.SetPluginVariable(A, "skill", "blade")? | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #1 on Sat 12 Nov 2005 01:14 PM (UTC) |
Message
| With the latest version you can use the BroadcastPlugin (or PluginBroadcast?) callback to send a message to any other plugins. The idea is that whoever catches the message can figure out what it means from its contents and perform any required actions.
For example, if your plugin B needs to set the "skill" variable in plugin A, it can send a message like "A_SetVariable_skill_value". Plugin A would then intercept this message and read it as:
"A" - this message is for plugin A.
"SetVariable" - I want you to set a variable
"skill" - this is the name of the variable you need to set
"value" - set the variable to this value.
Another way to do the same trick is to use aliases, which lets you communicate with the world file also, and not just other plugins.
| Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #2 on Sat 12 Nov 2005 01:19 PM (UTC) |
Message
| http://files.tagworld.com/919de069bc64bf71492fb9f1d8cf1b1b72a7.xml
This is a plugin that defines a basic message protocol using aliases, and allows you to gather and display information about various messages that different parts of your system exchange with each other.
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 12 Nov 2005 07:34 PM (UTC) |
Message
| It was a design decision to not let plugins or scripts change the variables of other plugins. Plugins are supposed to be self-contained, and the plugin author is entitled to think that its internal variables will not be changed without the plugin's consent.
However I could not see a problem with reading variables, so you can do that.
As Ked said, you can use a number of methods to "ask" a plugin to change its variables:
- CallPlugin
- Use an alias the plugin will intercept
- OnPluginBroadcast
The advantage of these methods is that the plugin can intercept them and choose whether or not to set the variable, for example after validating it is in range. Also it may need to take action if the variable is changed. |
- 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.
15,194 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top