BroadcastPlugin and OnPluginBroadcast giving strange errors

Posted by Elin on Sun 23 Jul 2006 10:01 AM — 2 posts, 12,725 views.

#0
Hello all:

In one of my plugins, I had originally set a function to broadcast something when it was done, with the intention of having the action set a flag in another plugin. I tried writing something, and it gave me an error, so I tried writing a simple test function to test the activatino of the BroadcastPlugin function.

I have an alias in Plugin2 that activates the following script:


def test1 (name, match, wildcards):
	world.BroadcastPlugin(1, "teststring")


In Plugin1, I have the following OnPluginBroadcast function written:


def OnPluginBroadcast (msg, id, name, text):
	world.note("Message received.")


Even though these functions look almost exactly like the examples that were given, MUSH is giving me the following error:

Quote:

Error number: -2147352567
Event: Execution of line 206 column 0
Description: Traceback (most recent call last):
File "<Script Block >", line 206, in test1
world.BroadcastPlugin(1, "teststring")
File "<COMObject world>", line 2, in BroadcastPlugin
COM Error: Type mismatch. (0x-7ffdfffb)
Line in error:
world.BroadcastPlugin(1, "teststring")
Called by: Immediate execution


Even weirder, I had it set to world.BroadcastPlugin(1, "test string")

and had OnPluginBroadcast do:

world.note(text)

This ended up with "test string" showing up in my window, but it still gave me the error.

Anyone who has had experience with these functions able to help?

-Elin
Australia Forum Administrator #1
I see what you mean. It seems the BroadcastPlugin call expects a return code. I got it to work by adding:


   return 1


... to the end of the function.

I never noticed this before, in VBscript it doesn't seem to care whether you return something or not.

For example:


def OnPluginBroadcast (msg, id, name, text):
  world.Note ("msg = " + str (msg))
  world.Note ("id = " + id)
  world.Note ("name = " + name)
  world.Note ("text = " + text)
  return 1