Closing a World Window?

Posted by Bludhound on Mon 23 Feb 2009 04:44 PM — 5 posts, 16,706 views.

#0
Hi, I have been searching for a function to close a world window, but to no avail. Basically, I would like the world window to close automatically upon disconnection. There doesn't seem to be an option for this, so I'm trying to write my own callback function to do this. Are there any better solutions to this? Thanks in advance!
Netherlands #1
Try a plugin with:


function OnPluginDisconnect()
  DoCommand("Close")
end


I am not sure how this would play if you had multiple windows open though, given the fact it posts messages to the command queue rather than really uses the world object. (In other words - it might just close the active world rather than the one that just disconnected.)

Additionally, to avoid the popup asking you to save, you might want to turn that off in the global configuration.

Edit: I just tested, and my suspicion was correct. It closes the currently active window. A simple timer in world #1 and a bunch of other worlds open which had the focus would one by one close the other worlds until the first world ended up as the one with the focus. As such, this solution will end up shooting in your foot if you use more than one world/window.
Amended on Mon 23 Feb 2009 05:03 PM by Worstje
#2
I guess it'll work if I can save the currently active world, make the disconnected world active, close it, then return to the inactive world. I'll give it a shot, thanks for the help!
Australia Forum Administrator #3
Activate it and then close.

eg.


function OnPluginDisconnect()
  Activate ()
  DoCommand("Close")
end


Alternatively, type this into the box for "Disconnect" on the scripting page:


!/Activate();DoCommand ("close")


Netherlands #4
I totally overlooked Activate(). I looked for a Focus/Activate in DoCommand(), but yeah. ^^ Glad there's a solution after all, though!