AcceleratorTo while using the Send To Script (12) option ends up executing the script in the world environment, rather than the environment of the plugin that registered the accelerator. I perceive this to be a bug, given the design of MUSHclient in other similar areas:
- Timers added using this option execute in the plugin.
- Triggers added using this option execute in the plugin.
- Aliases added using this option execute in the plugin.
The reason, as I understand, for the above functions to run in their own plugin is because plugins are not supposed to be able to interfere with the main world, at least not on a script level (hell, you can't even know if the main world is using Lua or VBScript, so it would never be reliable either).
Test case:
And execute this in your world (assuming Lua):
Guess which one shows up when you hit the Numpad0 button? :)
- Timers added using this option execute in the plugin.
- Triggers added using this option execute in the plugin.
- Aliases added using this option execute in the plugin.
The reason, as I understand, for the above functions to run in their own plugin is because plugins are not supposed to be able to interfere with the main world, at least not on a script level (hell, you can't even know if the main world is using Lua or VBScript, so it would never be reliable either).
Test case:
--Put this in a plugin:
AcceleratorTo ("Numpad0", "test_func()", 12)
function test_func()
Note("Plugin got called.")
end
And execute this in your world (assuming Lua):
function test_func()
Note("MAIN WORLD got called. This is bad!")
endGuess which one shows up when you hit the Numpad0 button? :)