Gammon Forum
Entire forum
MUSHclient
General
How to change focus to another already opened world window through scripting?
How to change focus to another already opened world window through scripting?
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| VBMeireles
Brazil (47 posts) bio
|
Date
| Wed 27 Jan 2016 02:29 PM (UTC) |
Message
| I have a couple of world windows open.
If I want to go to another world window I can either:
a. click its window;
b. click the Window menu and then the world I want to go to;
c. hit ALT+W and then the number of the world I want to go to (which is the same thing but using only the keyboard) or
d. hit CTRL+TAB or CTRL+SHIFT+TAB to cycle through opened worlds until I get to the one I want.
However, I'd like to be able to change focus through use of a script command. For example: ChangeFocusToWorldWindow("worldWindowId").
Is that possible? Does such a function exist? I wasn't able to find any that would do it from the alphabetical list. |
Vinícius | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #1 on Wed 27 Jan 2016 09:23 PM (UTC) |
Message
| Using Lua scripting (the default) an alias like this will do it:
<aliases>
<alias
match="foo"
enabled="y"
send_to="12"
sequence="100"
>
<send>
wantedWorldID = "f52a5090c219b0efebe1b521" -- or whatever
w = GetWorldById (wantedWorldID) -- get userdata item for wanted world
-- if not found, bail out
if not w then
ColourNote ("red", "", "Wanted world not open")
return
end -- if
-- activate (set the focus to) that world
w:Activate ()
</send>
</alias>
</aliases>
|
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
I made an alias "foo" to do it, but those same lines could be in a script somewhere.
To find the current world ID execute this script command:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| VBMeireles
Brazil (47 posts) bio
|
Date
| Reply #2 on Wed 27 Jan 2016 10:12 PM (UTC) |
Message
| Would I run into problems by calling GetWorldById("worldIdString"):Activate() directly? |
Vinícius | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #3 on Thu 28 Jan 2016 04:20 AM (UTC) |
Message
| You would if the world wasn't open because you would be attempting to call a function from a nil userdata. It is probably safer to have the test in-between. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
11,370 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.