Configuring numeric keypad to do alternative actions when required

Posted by Erendil on Tue 07 May 2002 01:55 PM — 2 posts, 12,583 views.

#0
I have problem with making a script. I want to change, by pressing "grey *" on Numpad, work of the numeric keys. When press first time "grey *" it means: 1=sw, 2=s, 3=se, 4=w etc. then when I will press again "grey *" then those numeric keys change meanings to for example: 1=sneak sw, 2=sneak s, 3=sneak se, etc...

Help me, please...

Erendil
Australia Forum Administrator #1
  1. Edit the "keypad" configuration, and change each direction to have "keypad_" in front of it, eg.

    
      keypad_north
      keypad_south
      keypad_east 
    


    and so on.

    Also change the keypad entry for the "*" to be:


    toggle_sneak

  2. Add the following script to your script file ...

    
    sub ToggleSneak (sName, sLine, aryWildcards)
     
      if world.GetVariable ("sneak") = "" then
        world.SetVariable "sneak", "sneak "
        world.note "Sneaking enabled"
      else
        world.SetVariable "sneak", ""
        world.note "Sneaking DISABLED"
      end if
    
    end sub
    


    What that does is, every time it is called, change a variable called "sneak" from empty to having the word "sneak " in it (note the trailing space).
  3. Make an alias to catch the keypad commands ...


    Alias: keypad_*
    Send: @sneak%1
    Expand variables: checked


    What that will do is convert (say) "keypad_north" to "@sneak north". If the variable "sneak" is empty then it just becomes "north" but if "sneak" contains the word "sneak" then it becomes "sneak north".
  4. Make an alias to catch the "toggle_sneak" command from the keypad ...


    Alias: toggle_sneak
    Label: togglesneak
    Script: togglesneak


    This means that when you hit the "*" button, it will generate the word "toggle_sneak". The above alias captures that and calls the "togglesneak" script. The script changes the value of the "sneak" variable. Then the other keypad keys behave appropriately. Have fun.