Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Night Vision scopes keybinding to MCM menu (DIK_M) #170

Open
axet opened this issue Jul 9, 2023 · 0 comments
Open

Add Night Vision scopes keybinding to MCM menu (DIK_M) #170

axet opened this issue Jul 9, 2023 · 0 comments

Comments

@axet
Copy link
Contributor

axet commented Jul 9, 2023

Hello!

Game has hardcoded keybinding for night vision scopes. This patch add MCM settings for keybinding for project "GAMMA/mods/G.A.M.M.A. Keybinds fixes".

If you want a pull request I can create one.

diff --git a/gamedata/scripts/bas_nvg_scopes.script b/gamedata/scripts/bas_nvg_scopes.script
index a36db7b..4b87b40 100644
--- a/gamedata/scripts/bas_nvg_scopes.script
+++ b/gamedata/scripts/bas_nvg_scopes.script
@@ -1,4 +1,4 @@
-local switch = DIK_keys.DIK_M
+switch = DIK_keys.DIK_M
 
 local nvg_type = 2
 local nvg_active
diff -ru --new-file a/gamedata/scripts/bas_nvg_scopes_mcm.script b/gamedata/scripts/bas_nvg_scopes_mcm.script
--- a/gamedata/scripts/bas_nvg_scopes_mcm.script	1970-01-01 03:00:00.000000000 +0300
+++ b/gamedata/scripts/bas_nvg_scopes_mcm.script	2023-07-11 10:44:43.473200078 +0300
@@ -0,0 +1,30 @@
+local op = { id = "nvm_keys", sh = true, gr = {
+         { id = "ui_keybind", type = "key_bind", val = 2, def = DIK_keys.DIK_M },
+       }
+     }
+
+function get_config(key)
+  local opt = ui_mcm and ui_mcm.get("nvm_keys/"..key)
+  if opt ~= nil then return opt else return defaults[key] end
+end
+
+function defaults(key)
+  for k,v in pairs(op["gr"]) do
+    if (op["gr"][k]["id"] == key ) then print(op["gr"][k]["def"]) end
+  end
+end
+
+function on_mcm_load()
+  return op
+end
+
+function on_option_change(mcm)
+  if mcm then
+      bas_nvg_scopes.switch = get_config("ui_keybind")
+  end
+end
+
+function on_game_start()
+  RegisterScriptCallback("on_option_change", on_option_change)
+  on_option_change(ui_mcm and ui_mcm.key_hold)
+end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant