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
➜ 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 (23,133 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 (23,133 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.
12,953 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top