[OBSOLETE] Key mappings

Discussion in 'Mod Discussions' started by oxide246, July 13, 2013.

  1. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    THIS MOD IS NOW OBSOLETE.

    Cola_Colin's hotbuild functionality is still being supported here if that's what you're after http://forums.uberent.com/forums/viewtopic.php?f=72&t=50260

    ------------------------

    Hey Guys, thought I might do something productive with my morning.

    I've created a key binding mod which allows you to map keys to in-game actions

    It is packaged in the format required by jacoby6000's lovely Mod Manager here:
    http://forums.uberent.com/forums/viewtopic.php?f=72&t=49518
    Although if you're not using this you can just unzip to your PA\media folder.

    EDIT: *removed old information*

    Version 1.4 changes
    ----------------------
    Added unit build bindings provided by Cola_Colin.
    Unit/Building bindings are stackable allowing you to bind a key twice.

    Version 1.3 changes
    ----------------------
    Mappings can be assigned on the Settings > Assign Keys page
    This version also includes Cola_Colin's hotbuild extension for binding building commands. For more information see below.
    Fixed an issue where commands would be issued when typing in the chat.

    There are two branches. One with a UI which I have been working on, and a "light" version without a UI which Cola_Colin has been working on. To edit bindings in Colin's branch look at the file at \PA\media\ui\keymapper\live_game\map.js

    Read below for more information.

    UI Version:
    Download Below

    [​IMG]

    [​IMG]

    Attached Files:

    Last edited: August 9, 2013
  2. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Re: [REL] Key mappings

    Sweet, key mappings for standard commands!

    Added to PA Released Mods list, and marked as Mod Manager compatible.
  3. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Key mappings

    Cool stuff, after I read this I wanted a mapping for the buildings so much, that I extended the mod to work like hotbuild from FA.

    You can download the modified version here: http://198.7.63.19/stuff/pa/mods/hotbuild_keymapper.zip

    With a few modification in the handling code the mapping can now look like this:

    Code:
    
    var energy = [
    	'/pa/units/land/energy_plant/energy_plant.json',
    	'/pa/units/land/energy_plant_adv/energy_plant_adv.json'
    ]
    
    var mex = [
    	'/pa/units/land/metal_extractor/metal_extractor.json',
    	'/pa/units/land/metal_extractor_adv/metal_extractor_adv.json'
    ]
    
    var factory = [
    	'/pa/units/land/vehicle_factory/vehicle_factory.json',
    	'/pa/units/land/vehicle_factory_adv/vehicle_factory_adv.json',
    	'/pa/units/land/bot_factory/bot_factory.json',
    	'/pa/units/land/bot_factory_adv/bot_factory_adv.json',
    	'/pa/units/air/air_factory/air_factory.json',
    	'/pa/units/air/air_factory_adv/air_factory_adv.json',
    	'/pa/units/sea/naval_factory/naval_factory.json',
    	'/pa/units/sea/naval_factory_adv/naval_factory_adv.json'
    ]
    
    var defense = [
    	'/pa/units/land/laser_defense/laser_defense.json',
    	'/pa/units/land/laser_defense_adv/laser_defense_adv.json',
    	'/pa/units/land/air_defense/air_defense.json',
    	'/pa/units/land/land_barrier/land_barrier.json'
    ]
    
    var radar = [
    	'/pa/units/land/radar/radar.json',
    	'/pa/units/land/radar_adv/radar_adv.json'
    ]
    
    var keyMap = {
    	
    	100:energy, //d
    	68:energy, //D
    	
    	119:factory, // w
    	87:factory, // E
    	
    	115:mex, //s
    	83:mex, //S
    	
    	101:defense, //e
    	69:defense, //E
    	
    	82:radar, //R
    	114:radar, //r
    	
    	113:{commands:5},	//Q - Patrol
    	121:{commands:-1},	//Y - Stop
    	97:	{commands:1}	//A - Attack
    }
    
    It cycles from the top down and skips buildings that are not available.

    I removed most of the original mappings, because personally I never use them. Do things like "roam" even work currently?

    I made a few quick testgames and it seems to work fine. However I got a few gui freezes. Dunno if they are a result of the mod. Does somebody else experience them? My knowledge of Javascript and PA modding is pretty limited, but I cant see anything in my code that could result in such a thing.
  4. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    Re: [REL] Key mappings

    Awesome stuff.

    I'm creating an in-game interface for updating the keys now. I'll incorporate your work into it too.
  5. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    Re: [REL] Key mappings

    Hey everyone.

    Just made an update which allows you to assign keys from the settings page. It even works on the fly when you go to the settings page in a live game!

    Thanks to Cola_Colin for his work with the "hotbuild" extension which is also included in this version.

    See above for download link.
  6. vipez

    vipez Member

    Messages:
    82
    Likes Received:
    13
    Re: [REL] Key mappings

    Good job there!

    Got a question for you,
    is it possible to change the binds for the camera movement? Instead of using the arrow keys, I'd like to use WASD instead :)
  7. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    Re: [REL] Key mappings

    From what I can tell all the current key bindings are done in the game "engine" layer and aren't available in the JavaScript. So I don't think there's any way to modify these. I don't see any engine call to rotate the camera either, so it's probably not possible at the moment. If anyone knows otherwise please let me know.

    I guess this mod is a bit of a temporary hack until Uber implement this properly.
  8. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Key mappings

    the version linked in the op doesnt work for me. The settings page is broken, it doesnt react to any clicks and doesnt show the version text.
  9. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    Re: [REL] Key mappings

    AHHHH I LUV UU!!!!

    I want this also but it doesn't work for me either, also would like for this to be compatible with yourlocalmadsci's Economy UI Mod v3
  10. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Key mappings

    I updated my version with the fix that stops it from doing things while chatting.
  11. neptunio

    neptunio Active Member

    Messages:
    124
    Likes Received:
    152
    Re: [REL] Key mappings

    Great stuff - Thanks guys!! :D
  12. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    Re: [REL] Key mappings

    Try downloading again now. I had trouble replicating this because PA takes data from a Sqlite database shared by all installs. After I nuked this I was able to replicate and fix.

    If you're interested, adding this to line 50 of PA\media\ui\alpha\keymapper\keymapper.js is what fixed it.

    Code:
    if(s.key == undefined) s.key = {};
  13. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    Re: [REL] Key mappings

    It should be a simple matter to merge the two. I will have a look at this later in the week when I get some free time.. as for now.. it's past my bed time :p
  14. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Key mappings

    I added bindings to build land and air units.
    Also I switch the order of the factories. Advanced factories are now first.
    I added pelter and lobber to E.

    For Units it is like this (it builds whatever is possible in the selected factor):

    s => engie
    d => scout
    w => arty/aa/air fighter
    e => tank/bot/bomber

    so "sd" and "we" are ordered like the ui if you use a german or english layout.

    oxide, when you have free time you can put these mappings into your current version. I looked over it and decided that I don't need to configure it in the UI, so I skipped that.
  15. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Re: [REL] Key mappings

    updated my branch once more so that Q and A are handled correctly, before this it was not possible to select patroul or attacks while pressing shift
  16. oxide246

    oxide246 Active Member

    Messages:
    249
    Likes Received:
    30
    Re: [REL] Key mappings

    Just posted another update which includes Cola_Colin's units update, and allows key bindings to be stacked for units/buildings.
  17. zaphodx

    zaphodx Post Master General

    Messages:
    2,350
    Likes Received:
    2,409
    Re: [REL] Key mappings

    I use the arrow keys to pan the map while playing. Is it possible to rebind these so I can keep my left hand on the left side of the keyboard and still use panning and keybinds?
  18. Clopse

    Clopse Post Master General

    Messages:
    2,535
    Likes Received:
    2,865
    Re: [REL] Key mappings

    haha zap. you should prob read the previous page.
  19. vipez

    vipez Member

    Messages:
    82
    Likes Received:
    13
    Re: [REL] Key mappings

    Already asked for it Zaphodx :lol:

    Seems like it isnt possible :?
  20. zaphodx

    zaphodx Post Master General

    Messages:
    2,350
    Likes Received:
    2,409
    Re: [REL] Key mappings

    Argh I guess we have to wait for keybinding support then. Takes a little to get used to but its quite a bit quicker using the panning keys.

Share This Page