How To Create A New Hotkey

A "hotkey" is a key on your keyboard which has a command assigned to it in JK's keyboard control options. Many of these hotkeys are linked to a cog. Others, such as jump, are handled by the engine. This tutorial will show you how to create your own hotkey and link it to a cog.

Here's an example of a hotkey's cog:

# Hotkey.cog
#
#==================================================#
symbols

message	activated

end
#==================================================#
code
#--------------------------------------------------------
activated:
     Print("Acitvated");

Return;
#--------------------------------------------------------
end

The activated message will be sent when the hotkey is pressed. When you press a hotkey linked to this cog, you should see "Activated" appear on the screen. If your hotkeyable bin is for an item (explained later), the deactivated message will be sent when you release the hotkey.

That's it for the hotkey cog, now to bind a hotkey to it. Put your cog in Resource\cog, put the items.dat in the Resource\misc folder, and put the jkstrings.uni in the Resource\ui folder. You can copy the items.dat and the jkstrings.uni out of the gob files in your resource folder. If you are using your own path folder (with the -path switch), then use that instead of the resourse folder.

Open up the items.dat. Scroll down to the bottom. The last bin in the items.dat is 115. Take up where LEC left off and use bin 116. Add the following into the items.dat after bin 115:

  binName     116     1   1   0x120   cog=hotkey.cog

Replace binName with whatever you want the bin named. The two ones are the minimum and maximum values of the bin that you can have. You can use the hotkey when you don't have anything in the bin, but if your bin is for an item (explained later), the selection box will flicker when it views the item.

The 0x120 is an Inventory Flag. This flag combines the 'hotkeyable' flag (0x100) and the 'available by default' flag (0x20). If the bin is not available, the hotkey will not work and it won't be shown in the selection box. You can use cog verbs to make the hotkey available, but using the 0x20 flag is easier in this case.

To send the deactivated message to your cog, you must make your hotkey bin an item like the fieldlight. To do this, add the flag 0x2 to your inventory flags. EG, 0x122. But as with any item, you will have to give it an icon for the item selection box.

To do this, first create an icon and convert it to a .bm file. Then place your bitmap in the Resource\ui\bm folder (create it if you have to). The name of the icon has three parts. The name begins with "ic" which stands for icon. The next part is the first five letters of your bin name. The last part is the number "8" for 8-bit or "16" for 16-bit. You will have to create an 8-bit and a 16-bit version of your icon. Here are the two icons for the example bin above:

  icbinna8.bm
  icbinna16.bm 

If the engine doesn't find these icon files, it will crash when you load a level.

Now save and close the items.dat. That's all you have to do with that file. Open up the jkstrings.uni. It's a big file, so search for the phrase "ACTIVATE16". Right under Activate16, add this:

  "ACTIVATE17"      0 "New Hotkey"

This will assign a name to your hotkey and make the engine look for another bin in the items.dat with the flag 0x100 to assign the new hotkey to. Save and close the jkstrings.uni.

Launch JK and go to the keyboard controls box. Scroll or page-down all the way down to the bottom. Double-click the new hotkey and then press the key you want to use for it. Now load a level and try out your new hotkey. If you used the hotkey cog given above, you should see a message print when you press the key.

In Jedi Knight, you can only add three hotkeys, but you can get many more in Mysteries of the Sith. To get around this shortage in JK, you can steal hotkeys away from items like the fieldlight. Just remove their 0x100 flag and take out their entries in the jkstrings.

  • Create:
This page was last modified 16:54, 14 April 2006.   This page has been accessed 1,896 times.