Jump to content

Has anyone gotten MCM hotkeys to work?


FlashyJoer

Recommended Posts

So I am trying to set up hotkey usage in a mod. I've got the keybinds.json set properly, as well as the section in the config.json. When I open my MCM in-game, I can select a hotkey and it is recorded into the settings/keybinds.json as expected and the MCM remembers the hotkey I chose.

 

But when I try to press this key ingame, nothing happens. I am using a string property declaration to obtain the value of the ID for the hotkey in the MCM, as follows:

 

String property MCMHotkeyID = "MCMHotKey" autoreadonly

 

And then I am using an OnControlDown Event, as shown in the MCM help wiki (note that my keybinds is a SendEvent type to the proper mod and formid for the quest that the script is attached to - it is the ONLY script attached to that formid). EDIT: I have also tried using an OnControlUp event as well, to no avail...

 

Event OnControlDown(String sKey)

If sKey == MCMHotKeyID

Debug.Notification("Key Press Registered!")

Endif

EndEvent

 

Even this little test does nothing - no message displays. So I ask of anyone with insight into the hotkey setup in MCM, am I missing something / got something wrong on the papyrus side of this, since I can verify the actual MCM is recording the hot key selected? In any source code I could find where people are using hotkeys, they all seem to be working with just this, so I am stumped...

 

Appreciate the help!

Edited by joerqc
Link to comment
Share on other sites

Still stuck and nothing I do fixes this... all other mods that use MCM hotkeys are working fine and I have cloned their every step to no avail - I cannot get my mod to activate a function when hotkey is pressed even though the MCM registers the fact that the hotkey is set and recorded to the keybinds.json in the settings folder.

 

Has noone ever created hotkeys for their mod using MCM that can help?

Link to comment
Share on other sites

  • 3 weeks later...

To circle back on this, as I was able to find out how to resolve it, for anyone in the future who faces similar issues.

 

All of the code was good and should have been operational, per the guidelines on the WIKI. The problem was that my receiving script was attached to a reference alias and not directly on the quest (Script Tab). Ref Aliases do not have a FormID and thus cannot receive the event that the MCM is sending for OnControlUp or OnControlDown.

 

To get around this I needed to decide whether or not I would leave the script where it was on the Ref Alias or to convert it to extend Quest. Since I needed Object References to be native (OnEqupItem and OnUnequipItem events), I kept it as a Ref Alias script. This meant I had to do the following:

 

1. Create an interceptor script to run on a QUEST level. In that script, all there is a property for a custom event declaration and the OnControlDown event that registers the MCM hotkey and then sends a custom event.

 

2. I had to modify the ref alias script to receive the custom event and to add an event to be triggered on 'hearing' the send from the interceptor.

 

Once these two things were done, my hotkeys began working as I intended them to.

 

Kind of wish the documentation on the WIKI for MCM was a little less ambiguous about the placement of the receiving script on the QUEST level and not on the REF ALIAS level. Or perhaps that is just my inexperience to not understand it... either way, a direct statement would have gone a long way to make this clear.

Edited by joerqc
Link to comment
Share on other sites

  • 2 weeks later...

I just found this thread and it has been a life saver. I had the exact same situation as you, where my script was a reference alias, not quest, and MCM hotkey functionality wasn't finding my script. When I created a new script as a quest, it worked, as you also found. Thanks for posing the solution!

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...
So I just have to say this, a video tutorial would be amazing for MCM. Having used it now for a year, I still find myself having to look to threads to fix issues in my encoding packets. Thank you so much for this fix btw. It was amazingly helpful.
Link to comment
Share on other sites

Here's how I implement hotkeys. They work similar to scaleform callbacks.

 

In my config.json, I'll have the input for my hotkey

{
     "id": "Hotkey1_ID",
     "text": "Name of Hotkey",
     "type": "hotkey"
}

Then in keybinds.json

{
     "id": "Hotkey1_ID",
     "desc": "Whatever your hotkey does",
     "action": {
         "type": "CallFunction",
	 "form": "MODNAME.esp|FORMID",
	 "function": "CallHotkey1"
     }
}

Naturally, MODNAME.esp is the name of your mod, and FORMID is the unique ID that refers to your quest you have your MCM control script attached to.

In your control script, you'll have a simple function

Function CallHotKey1()
     ;code for whatever your hotkey needs to do
EndFunction

If you want to make sure your hotkey is being called, you can always add a trace to the top of the papyrus function. That will at least spit out into the papyrus log that the callback worked. And since these are simple callback functions, they should have no passed arguments. If you want to call a function that has arguments in its call, then make your hotkey's callback call that function.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...