BroadcastPlugin / OnBroadcastPlugin

Posted by Mr.lundmark on Thu 17 Sep 2009 05:11 PM — 4 posts, 19,888 views.

#0
If I have this in one of my functions in a python plugin:

world.BroadcastPlugin(100, "hello")

and in another python plugin:
def OnPluginBroadcast (msg, id, name, text):
world.Note("toodles")

and in a third plugin, this time in lua:
function OnPluginBroadcast (msg, id, name, text)
end

then I get these errors:

Script error
World: p
Execution of line 495 column 0
Immediate execution
Traceback (most recent call last):
File "<Script Block >", line 495, in RunPath
world.BroadcastPlugin(100, "hello")
File "<COMObject world>", line 2, in BroadcastPlugin
COM Error: Type mismatch. (0x-7ffdfffb)
Line in error:
world.BroadcastPlugin(100, "hello")

It goes away if I remove the OnPluginBroadcast in the second-python plugin.

Or is it really something that I missed? :)
#1
Actually, the Lua-script doesn't even need to be there. If I simply try to call a PluginBroadcast() from one python plugin and catch it in another python plugin, I seem to be getting these errors.
Netherlands #2
Somehow, MUSHclient, the WSH and the Python scripting engine have a conceptual disagreement about functions being called. I don't know why, but I do know how to solve it! :)

def OnPluginBroadcast (msg, id, name, text):
   world.Note("toodles")
   
   return 0


The return 0 makes all the difference. I ran into this with OnPluginSent() and other callbacks that don't require you to return a value, but with Python end up as a requirement due to this quirk. :)
Amended on Thu 17 Sep 2009 09:33 PM by Worstje
#3
Ahhhh... I see, thanks Worstje.

That should definetly be added to the documentation.