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, 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.
 Entire forum ➜ MUSHclient ➜ General ➜ Keyboard /commands &Scripting

Keyboard /commands &Scripting

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


Posted by Darren Hill   (4 posts)  Bio
Date Sat 18 Aug 2001 09:18 PM (UTC)
Message
Well, I hope I've got the right section here. =)

I definately prefer using MUSHclient to every other client I've used - but there's one thing I've found lacking, that keeps me going back to a certain other client over and over again: /commands.

Or specifically: /connect (world), /toggle, /disconnect and /world (world #)

I find these /commands to be wonderful things (especially for those of us who hate using our mouse, and don't like using various ctrl or alt combinations) - which, are unfortunately lacking from MUSHclient. I thought about the possibility of scripting commands to create equivalents (Much like someone scripted a version of /grab awhile back) - especially /toggle and /world, but I am a -total- scripting neophyte (in any language!)

Is it even possible to duplicate the effects of these under MUSHclient? If so - anyone able to help me out with doing so? ^_^

Darren

Top

Posted by Nick Gammon   Australia  (23,057 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 19 Aug 2001 06:37 AM (UTC)

Amended on Sun 19 Aug 2001 07:11 AM (UTC) by Nick Gammon

Message
I'm not sure what these commands do in your "other client" but I will try to guess. Each of those can be done with a bit of scripting (my examples are in VBscript) and an alias (to call the script easily).



connect (world)

I assume this it to open another world and connect to it. You can do this in MUSHclient by using "world.open".

Once you have enabled scripting, with VBscript as the language, you can simply type in the command window:


/world.open "worlds/smaug.mcl"


However to save a bit of typing you can make an alias, so you simply type:


openworld smaug


This alias (openworld) calls the script routine below, that tacks the directory in front, and ".mcl" at the back, opens the world, and activates it.



toggle

I assume this is to change from one world to the next. You could add the ToggleWorld script to your script file, and make a simple alias that called it. The one I have written goes from the current world to the next one. You would need to put the alias into each world.



disconnect

You could do this with and alias and script too, otherwise simply type:


/world.disconnect





world (world #)

This also uses a simple script to get a list of the active worlds, and then goes to the one you nominate. You can call that with a simple alias, eg.


Alias: world *
Label: GoToWorld
Script: GoToWorld


Then just type in: world 4



The stuff below goes into the script file ...


' ---------------------------------------------------------
' Example of opening another world from an alias.
'
' Alias: openworld *
' Label: OpenWorld
' Script: OpenWorld
' ---------------------------------------------------------
Sub OpenWorld (thename, theoutput, thewildcards)
dim otherworld
dim filename

  filename = "worlds\" & thewildcards (1) & ".mcl"
  set otherworld = world.open  (filename)

  if otherworld is nothing then
    world.note "Could not open world file " & filename
  else
    otherworld.activate
  end if
  
End Sub

' ---------------------------------------------------------
' Example of toggling from one world to the next
'
' Alias: toggle
' Label: ToggleWorld
' Script: ToggleWorld
' ---------------------------------------------------------
Sub ToggleWorld (thename, theoutput, thewildcards)
  dim mylist
  dim i
  dim thisworld
  dim otherworld

  thisworld = 0

  ' get list of worlds
  mylist = world.GetWorldList

  ' find which world we are
  If not IsEmpty (mylist) then
    for i = lbound (mylist) to ubound (mylist)
      If world.WorldName = mylist (i) then
         thisworld = i
      End If
  next
  End If
 
  ' find next world, wrap around at end of list
  if thisworld >= ubound (mylist) then
     thisworld = lbound (mylist) 
  else
     thisworld = thisworld + 1
  End If

  ' get reference to next world
  set otherworld = world.GetWorld (mylist (thisworld))

  ' activate it
  If not (otherworld is nothing) then
    otherworld.activate
  End If

End Sub


' ---------------------------------------------------------
' Example of going to another world
'
' Alias: world *
' Label: GoToWorld
' Script: GoToWorld
' ---------------------------------------------------------
Sub GoToWorld (thename, theoutput, thewildcards)
  dim mylist
  dim i
  dim otherworld

  ' get list of worlds
  mylist = world.GetWorldList

  i = cint (thewildcards (1))

  if i < lbound (mylist) or i > ubound (mylist) then
     world.note "You do not have a world number " & i
     exit sub
  End If

  ' get reference to next world
  set otherworld = world.GetWorld (mylist (i))

  ' activate it
  If not (otherworld is nothing) then
    otherworld.activate
  End If

End Sub


- Nick Gammon

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

Posted by Darren Hill   (4 posts)  Bio
Date Reply #2 on Mon 20 Aug 2001 12:39 AM (UTC)
Message
*chuckles* Sorry, it's an old habit of mine - discussion forums/BBSs for one program for some reason not wanting others mentioned in their messages - so I did it without even thinking about it. O.o

You hit them all perfectly with their functions, I'm sorry I didn't explain what they did. *sighs* I figured them to be fairly self-explanatory, but by the time I realized I might want to go in and explain what they did (now *cough*) you'd already replied. All I can say is... wow, thanks! And now, I feel like some of that I really should have been able to figure out some of it on my own. Thanks for the prompt reply, and the GREAT help!

Once I get these working, consider the registration fee on its way... er, well, once I've made a payment or two on my card at least. ^_^

Darren
Top

Posted by Darren Hill   (4 posts)  Bio
Date Reply #3 on Mon 20 Aug 2001 04:34 AM (UTC)
Message
I finally got to get this script set up and everything and tried it out. It works great! Save for one little thing that annoyed me: the 'world' portion (GoToWorld in the script.) It starts its numbering of the worlds from 0 and not 1 - so that if you tried to do a 'world #' and entered the world that had activity on the activity bar - it wouldn't go to that one.

So, I decided to play around. ^_^ In case anyone else out there decides to use this awesome script that Nick did (I think it's awesome anyway!) I found that if you change this line:

i = cint (thewildcards (1))

to this:

i = cint (thewildcards (1)-1)

you can enter the number highlighted in the activity bar - and you get to the correct world.
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,463 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.