Register forum user name Search FAQ

Gammon Forum

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 ➜ Plugin Communication

Plugin Communication

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Sikai   (2 posts)  Bio
Date Mon 12 Oct 2009 05:09 AM (UTC)
Message
Basically here's the problem:
I need a plugin to get_a_world, draw a miniwindow and add a hotspot in the new window.

I can get the plugin to open the window and draw a miniwindow in it, however the hotspot callbacks are never called.


	local mapget = get_a_world("MapGet", "Aardwolf")
	if mapget then
		win = GetPluginID()
		local w_width = mapget.GetInfo(264)
		local w_height = mapget.GetInfo(263)
		Note(w_width)
		Note(w_height)
		mapget:WindowCreate(win, 0, 0, w_width, w_height, 0, 0, ColourNameToRGB("white"))
		mapget:WindowLoadImage(win, "im", location)
		mapget:WindowDrawImage(win, "im", 0,0,w_width,w_height, 2,0,0,0,0)
		mapget:WindowAddHotspot(win, "hs1", 0, 0, w_width,w_height, "", "", "", "", "mouseup",
								"Zoom", 10, 0)
		mapget:WindowShow(win, True)
   


I tried installing a helper plugin in the new world window which would handle the drawing and adding a hotspot, the idea being perhaps the hotspot callback function was out of scope. But doing it that way, I can't get the main plugin in the main window to communicate with the helper plugin in the other world.

What to do????
Top

Posted by Nick Gammon   Australia  (23,166 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 12 Oct 2009 06:37 AM (UTC)
Message
Personally I am moving away from multiple, dummy, worlds in favour of doing everything in the main world (which can be a large window) rather than having to carefully position multiple world windows and handle the focus and related problems.

Hotspot callbacks will need to be added in the plugin that implements the callback. Thus, if you have a helper plugin, that helper plugin needs to be the one that installs the hotspot.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #2 on Mon 12 Oct 2009 06:38 AM (UTC)

Amended on Mon 12 Oct 2009 06:43 AM (UTC) by Twisol

Message
Interesting problem. How were your plugins communicating initially? I imagine a combination of GetPluginVariable() and CallPlugin(). I can't tell entirely from this code snippet, but have you tried using GetWorldById(<other world ID>), and using the returned world to CallPlugin() across? Like:


w = GetPluginById("4a6110b2c72e8b8101abb263")
w.CallPlugin("775d4e95358a9244aa4fbebe", "function_to_call", "string parameter")



EDIT: In light of Nick's post, you might want to try sending a string-dumped Lua function through to the other plugin. Something like this:


hotspot_callback = function()
  Note("Called!")
end

local dumped_func = utils.base64encode(string.dump(hotspot_callback))

w = GetPluginById("4a6110b2c72e8b8101abb263")
w.CallPlugin("775d4e95358a9244aa4fbebe", "function_to_call", dumped_func)


On the other side, you'd use this to unserialize the function:


hotspot_callback = loadstring(utils.base65decode(param))()


That way, if it's the other plugin that's creating the hotspot, it'll also have the function, even though it came from another plugin. (Still think function serialization isn't useful, Nick? ;) )

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,166 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 12 Oct 2009 06:46 AM (UTC)
Message
Can't you just send the function source?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #4 on Mon 12 Oct 2009 06:51 AM (UTC)
Message
Now you mention it, yes, you could; that's how my LoadPPI file worked. It sort of depends on what you want, I guess.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Sikai   (2 posts)  Bio
Date Reply #5 on Mon 12 Oct 2009 04:21 PM (UTC)
Message
I ended up taking the easy way out and had the initial plugin Execute a command on the client window, then in the client window an alias captures the command and sends it to the helper plugin
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.


18,221 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.