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 ➜ Suggestions ➜ "Anchoring" a world to ctrl-#?

"Anchoring" a world to ctrl-#?

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


Posted by Thistle-Chaser   (4 posts)  Bio
Date Mon 22 Apr 2002 09:28 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 23 Apr 2002 02:35 AM (UTC)
Message
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.

- Nick Gammon

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

Posted by Thistle-Chaser   (4 posts)  Bio
Date Reply #2 on Tue 23 Apr 2002 04:49 AM (UTC)
Message
Woo. Thanks!
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.


14,044 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.