"Anchoring" a world to ctrl-#?

Posted by Thistle-Chaser on Mon 22 Apr 2002 09:28 PM — 3 posts, 14,625 views.

#0
Hello,

Once you have your worlds open, you can use ctrl-<some number> to switch through them. It would be really handy if you could permanently "hook" a world to that ctrl-#. Like ctrl-5 will always either open joe@joeMUSH or take you to that window if it's already open. Or if that would be hard, then maybe some other key combination? Like alt-# to open joe@joeMUSH all the time?

Thank you,
Thistle
Australia Forum Administrator #1
There are a couple of ways you could do this. The simplest is to go into File -> Global Preferences and add the appropriate world files to "Worlds to open at startup".

Then each file will always be in the same order, so you can always use Ctrl+5 to open the fifth world.

However a more complex solution, that would allow for you to get to a world that might not be open yet, is to use the "world.open" script function in a small script.

First, add a function like this to your scripts files (example in VBscript) ...


Sub OpenPennMUSH (AliasName, AliasLine, arrWildcard) 
  world.open "c:\mushclient\worlds\PennMUSH.mcl"
end sub


This sub is designed to be called from an alias. Now, add an alias using the world configuration screen (you might want to add it to all the worlds you have open, or alternatively use the "default aliases" idea, and share one set of aliases between worlds, if that will work for you.

Let's assume you don't plan to actually type the alias, so make it something you won't normally use, like this:


Alias: _open_PennMUSH_
Label: OpenPennMUSH
Script: OpenPennMUSH


What this will do, if it sees "_open_PennMUSH_" typed, is to call the script OpenPennMUSH (shown above) which will do a world.open to open that world.

Finally, add a "macro" which maps a keystroke to some text. Using world configuration again, open the "macros" dialog, and choose one (eg. F2). Make it read:


Send: _open_PennMUSH_
Send now: checked


The net effect of all this will be, if you press F2, then:

  1. F2 will send "_open_PennMUSH_"
  2. "_open_PennMUSH_" will be trapped by the alias
  3. The alias will call the script OpenPennMUSH
  4. The script OpenPennMUSH will attempt to open the world file.


The important point here is that if the world file is already open, then MUSHclient just switches to it, so the key will open the world, or switch to it, whichever is appropriate.




If you want to do this to lots of worlds you could modify the above slightly to allow for any world to be opened. Something like this:

Script file:


Sub OpenAnyWorld (AliasName, AliasLine, arrWildcard) 
  world.open "c:\mushclient\worlds\" & arrWildcard (1) & ".mcl"
end sub


This script now expects the world name (file name) as the first wildcard.

Then make the alias do this:


Alias: _open_AnyWorld_ *
Label: OpenAnyWorld
Script: OpenAnyWorld


The alias now expects the world name as an argument.

Finally, modify the macro to supply the right name ...


Send: _open_AnyWorld_ PennMUSH
Send now: checked


The advantage of this method is you can now make F3 open a different world, eg.


Send: _open_AnyWorld_ SMAUG
Send now: checked


And, F4 could open another again, and so on. All sharing the same alias and script.
#2
Woo. Thanks!