[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Switching worlds from command line MultiWorld
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Switching worlds from command line MultiWorld

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


Posted by Cyote   (9 posts)  [Biography] bio
Date Tue 20 Oct 2015 05:38 PM (UTC)
Message
Hi,

Is there a way to send commands directly from commandline or switching worlds with commands without using accelerator keys like zmud/cmud/tintin style??

Thank you.
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Tue 20 Oct 2015 07:07 PM (UTC)
Message
Quote:
without using accelerator keys

Why without?

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Tue 20 Oct 2015 07:55 PM (UTC)

Amended on Tue 20 Oct 2015 07:58 PM (UTC) by Nick Gammon

Message
You need a "world reference" which you can get by name or world ID code. Safer is the ID string, because that won't change if you rename the world. With scripting enabled, and "/" as the "script" character, type:


/print ( GetWorldID () )


(Or use the Immediate Window (Ctrl+I) and leave out the slash.

You should see something like this in your output window:


f52a5090c219b0efebe1b521


That is the "world ID" (in my case, for my test world).

Now you can, in the command window (and again, assuming scripting is active and you have "/" as the scripting prefix) type:


/GetWorldById ("f52a5090c219b0efebe1b521"):Activate ()


That gets a "world reference" to that particular ID, and then calls the Activate function for that world, bringing that world to the front.

To switch back, you need the ID of the other word, eg.


/GetWorldById ("8c1e6fc91017ec9408ced4c0"):Activate ()





Template:function=GetWorldID GetWorldID

The documentation for the GetWorldID script function is available online. It is also in the MUSHclient help file.



Template:function=GetWorldById GetWorldById

The documentation for the GetWorldById script function is available online. It is also in the MUSHclient help file.



Template:function=Activate Activate

The documentation for the Activate script function is available online. It is also in the MUSHclient help file.






Now you can make an alias, if wanted, to save all that typing, eg.


<aliases>
  <alias
   match="world3"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>GetWorldById ("f52a5090c219b0efebe1b521"):Activate ()</send>
  </alias>
</aliases>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.





This simple approach will give an error message if the wanted world is not open. You could make the alias "smarter" and test if GetWorldById returns nil or not:


<aliases>
  <alias
   match="world3"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

local w = GetWorldById ("f52a5090c219b0efebe1b521")

if w then
  w:Activate ()
else
  ColourNote ("red", "", "Requested world is not available")
end

</send>
  </alias>
</aliases>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 20 Oct 2015 08:05 PM (UTC)
Message
If you have short and easily-remembered world names (in the configuration dialog -> General -> IP address part) then you could use the name, like this:


/GetWorld ("smaug2"):Activate ()


Then you could make a single alias that takes a wildcard, and substitute that into the GetWorld part, and have it switch to any world.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


2,270 views.

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

Go to topic:           Search the forum


[Go to top] 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.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]