JamesWilko / Payday-2-BLT-Lua

Mods folder that controls the ingame aspects of the Payday 2 BLT.
MIT License
16 stars 26 forks source link

Options menu items of type "keybind" can be defined in JSON menus. #30

Closed TdlQ closed 7 years ago

TdlQ commented 7 years ago

To take the existing example of Keepers, I define:

{  
    "type" : "keybind",
    "id" : "kpr_keybind_follow",
    "title" : "kpr_keybind_follow_title",
    "description" : "kpr_keybind_follow_desc",
    "keybind_id" : "keepers_follow",
    "run_in_game" : true,
    "func" : "KeybindFollow"
},

(func KeybindFollow points to MenuCallbackHandler.KeybindFollow)

The mod's options menu looks like: http://i.imgur.com/4UfXmYQ.jpg (see 2 keybinds in the bottom)

Mod keybinds manager's options menu looks like: https://i.imgur.com/cFmdoAX.jpg

aylz10 commented 7 years ago

Can set hotkey,but it is not work in the game.

TdlQ commented 7 years ago

It works but mods need to adapt to the new system. I've tested with Keepers and GoonMod's Custom Waypoints but haven't pushed the updates as I can't be sure if this pull request will be accepted as is.

aylz10 commented 7 years ago

How to adapt to the new system?

TdlQ commented 7 years ago

Err, I think everything is said in the first comment.

TdlQ commented 7 years ago

No, for the JSON of the first post corresponds this function:

MenuCallbackHandler.KeybindFollow = function(this, item)
    log('My keybind logged something!')
end
aylz10 commented 7 years ago

ty