Adds a helper entitytemplate for developers who wish to add custom key bindings into their mod.
- Toggling the
m_bEnabled
property results in the keybinds not being set correctly if you are using the dynamic object method. I suspect the game for some reason falls back to them_sModifierKeyName
andm_sKeyName
properties.- Workaround: Use the Enable/Disable pins instead or send the
NotifyDataChanged
input pin to the dynamic object entity for the keybinds to get restored.
- Workaround: Use the Enable/Disable pins instead or send the
This helper mod allows you to setup custom keybinds which you can then use to fire pins in your mod. Please reference this mod in the "requirements" section in your mod's manifest like so:
"requirements": [
"Notex.SimpleKeyEventHelper"
]
There are two methods of using this mod:
- First method: With this method you can just use the
m_sModifierKeyName
andm_sKeyName
properties in theSimpleKeyEventHelper
entity to configure the keybind. - Second method: This method involves using a dynamic object entity referenced in a property called
m_pDataProvider
in theSimpleKeyEventHelper
entity. The second method can be used if you wish to provide customisability options in your SMF mod without having to use duplicated entity.json or entity.patch.json files.
SimpleKeyEventHelper entity:
{
"parent": null,
"name": "SimpleKeyEventHelper",
"factory": "[assembly:/Templates/UI/Controls/simplekeyeventhelper.template?/SimpleKeyEventHelper.entitytemplate].pc_entitytype",
"blueprint": "[assembly:/Templates/UI/Controls/simplekeyeventhelper.template?/SimpleKeyEventHelper.entitytemplate].pc_entityblueprint",
"properties": {
"m_sModifierKeyName": {
"type": "ZString",
"value": "None"
},
"m_sKeyName": {
"type": "ZString",
"value": "F7"
}
},
"events": {
"Pressed": {},
"Down": {},
"Up": {}
}
}
SimpleKeyEventHelper entity:
{
"parent": null,
"name": "SimpleKeyEventHelper",
"factory": "[assembly:/Templates/UI/Controls/simplekeyeventhelper.template?/SimpleKeyEventHelper.entitytemplate].pc_entitytype",
"blueprint": "[assembly:/Templates/UI/Controls/simplekeyeventhelper.template?/SimpleKeyEventHelper.entitytemplate].pc_entityblueprint",
"properties": {
"m_pDataProvider": {
"type": "SEntityTemplateReference",
"value": "cafe4e160a2ca171"
}
},
"events": {
"Pressed": {},
"Down": {},
"Up": {}
}
}
Dynamic Object entity:
{
"parent": "cafe22132fb215d4",
"name": "DynamicObject",
"factory": "[modules:/zdynamicobjectentity.class].pc_entitytype",
"blueprint": "[modules:/zdynamicobjectentity.class].pc_entityblueprint",
"properties": {
"m_pJSONResource": {
"type": "ZRuntimeResourceID",
"value": "[assembly:/your/path/here.json].pc_json"
}
}
}
JSON file:
{
"modifier": "None", // Possible options are: None, Alt and Control
"key": "F2" // Possible values can be found here (ones with uint not string. "Example: F2 : uint = 113"): https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/Keyboard.html
}
m_bEnabled
: bool (defaults to true)m_sModifierKeyName
: ZString (defaults to "None")m_sKeyName
: ZString (defaults to "")m_pDataProvider
: SEntityTemplateReference (defaults to null)
See JSON example above for possible m_sModifierKeyName and m_sKeyName values
Enable
: void (Enables keybinds)Disable
: void (Disables keybinds)
Pressed
: void (Fires on key pressed down and repeats if held for over a second)Down
: void (Fires on key pressed down)Up
: void (Fires on key released)