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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Changing Accelerators by Groups

Changing Accelerators by Groups

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


Posted by Myrilith   (5 posts)  [Biography] bio
Date Sat 20 Oct 2007 11:39 PM (UTC)
Message
I run MUSHClient from a laptop keyboard, so I'm missing the keypad to use for simple directions. I've worked out a system of Accelerators to make up for this, usually along the lines of

Accelerator "CTRL+8", "north"


I've also got a secondary set of accelerators to meet some of the common functions, and these are like

Accelerator "CTRL+ALT+8", "drink mana"


What I'm trying to do is establish a kind of group of accelerators, so that I can change modes and thus change the keybindings. For example, the CTRL+ALT+8 combination would
drink mana
if I was in, say, "Magic" mode, but if I was in "Combat" mode it would
drink health
instead. I also have a third Debate mode.

I've worked out a system using an accel_mode variable and if-then statements to adjust what set of actions my accelerators perform. The problem that I'm running into is that if I have to re-process the script every time I change modes, or it won't register the change. It looks something like this:

if GetVariable ("accel_mode") = "combat" then
 Accelerator "CTRL+ALT+8", "drink health"
end if

if GetVariable ("accel_mode") = "magic" then
 Accelerator "CTRL+ALT+8", "drink mana"
end if

if GetVariable ("accel_mode") = "debate" then
 Accelerator "CTRL+ALT+8", "drink bromide"
end if


If I switch modes and then re-process, it will do whichever set of actions accompanies the mode I'm in. But if I don't reprocess, I can switch modes as many times as I want and it will only do one set, the mode that was in place the last time the script was processed.

There -has- to be a better way to do this. ^.^ (BTW, I've also tried using ELSE IF statements, but didn't have any success at all with it.) What can I do?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 21 Oct 2007 01:18 AM (UTC)
Message
How do you switch modes? This seems like the time to redo the accelerators.

Another way would be to make generic aliases that decide at the last moment what to do, eg.


Accelerator "CTRL+ALT+8", "ctrl+alt+8_alias"


Now make an alias which matches on "ctrl+alt+8_alias" and have it make the decision in its script (based on your current mode).

However I think it is simpler just to redo the group of accelerators at the moment you change modes.

- Nick Gammon

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

Posted by Myrilith   (5 posts)  [Biography] bio
Date Reply #2 on Sun 21 Oct 2007 02:45 AM (UTC)
Message
Ha! That's fantastic, Nick. For some reason, I thought that accelerators had to be loaded in some sort of world-wide script, like the one I load on startup.

It fixed a world of problems -- with this and several other things -- knowing that accelerators can be changed spontaneously like other scripts, they don't have to be... preserved... anywhere. Thanks!
[Go to top] top

Posted by Myrilith   (5 posts)  [Biography] bio
Date Reply #3 on Tue 23 Oct 2007 03:43 PM (UTC)
Message
Okay, that worked. I went on, crafted almost the entirety of my system, and now I'm coming back to this:

Is there any way to send Accelerator commands into the command history? If it's a simple statement then I can do it without any trouble by using
Accelerator "ALT+9","/SendPush ""say Hello!"""
Several of my accelerators, though, are set to fire an alias, and I can't get these aliases to work.

For example, if I had an alias "sayhi" that would send "say Hello!" to the world, it doesn't work to use
Accelerator "ALT+9","/SendPush ""sayhi"""
I can't get it to recognize that this is an alias. (BTW, I know it's a valid alias, because it works if I type it directly into the command window.)

Is there any way to make an Accelerator send an alias both into the command history and to execute immediately?
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #4 on Tue 23 Oct 2007 04:02 PM (UTC)
Message
The alias could do a sequence of PushCommand();SetCommand("alias itself");PushCommand(), to clear the command window, add its own match text to the window, and then clear it again, pushing itself into the command history.

If you want to keep the original text in the command window, then I suppose something like this should do it:


prev_command = GetCommand()
SelectCommand()
PasteCommmand("alias")
PushCommand()
SetCommand(prev_command)

[Go to top] top

Posted by Myrilith   (5 posts)  [Biography] bio
Date Reply #5 on Tue 23 Oct 2007 06:54 PM (UTC)
Message
Oh, okay -- I think I get it.

So I should set the alias itself to put the command in the history. Instead of just setting the alias to send "say Hello!" to the World, send something like "world.sendPush "say Hello!"" to Script.

Again, a simple solution. ^.^ Thanks.
[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.


16,538 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 HostDash]