NOTE: All script examples in this post are done in Squirrel script. RF2's primary scripting language is still Python at the moment.
Action maps are key/mouse mappings that are defined for the game. Let's say you don't want to use ESC to get to your menu...now you don't have to...just bind the key that you want to a script function that displays the menu.
Example (in Squirrel code):
Code: Select all
// Global action map is the default action map created by the RF2 shell...
local map = RF2GetInput().GetActionMap("Global");
map.bind(KEY_F12, "show_menu");
function show_menu()
{
RF2GetGame().setState("MenuState");
}
Example:
Code: Select all
// Global action map is the default action map created by the RF2 shell...
local map = RF2GetInput().GetActionMap("Global");
map.bind(KEY_F12, "show_menu");
map = RF2ActionMap("MenuMap");
map.bind(KEY_ESC, "menu_exit");
function show_menu()
{
RF2GetGame().setState("MenuState");
RF2GetInput().setCurrentActionMap("MenuMap");
}
function menu_exit()
{
RF2GetGame().setState("GameState");
RF2GetInput().setCurrentActionMap("Global");
}