Divergent/mods/Quick Load Last Save/gamedata/scripts/qrs_key_mcm.script

88 lines
2.3 KiB
Plaintext

local KEY = DIK_keys.DIK_F12 --change this if you don't use MCM or havn't updated to the curent version
local mode = 0
local modifier = 0
local mcm_keybinds = ui_mcm and ui_mcm.key_hold
function on_mcm_load()
local options = {
id = "rax_qrs",
sh = true,
gr = {
{id = "rax_qrs", type = "slide", link = "ui_options_slider_player", text = "ui_mcm_menu_rax_qrs", size = {512, 50}, spacing = 20},
{id = "keybind", type = "key_bind", val = 2, def= KEY},
{id = "modifier", type = ui_mcm.kb_mod_radio, val = 2, def = 0, hint = "mcm_kb_modifier" , content= { {0,"mcm_kb_mod_none"} , {1,"mcm_kb_mod_shift"} ,{2,"mcm_kb_mod_ctrl"}, {3,"mcm_kb_mod_alt"}}},
{id = "mode", type = ui_mcm.kb_mod_radio, val = 2, def = 0, hint = "mcm_kb_mode" , content= { {0,"mcm_kb_mode_press"} , {1,"mcm_kb_mode_dtap"} , {2,"mcm_kb_mode_hold"}}},
{ id= "desc_mcm" ,type= "desc" ,text= "ui_mcm_rax_qrs_update_mcm" ,clr= {255,175,0,0}, precondition = {function() return not mcm_keybinds end} },
}
}
return options
end
function on_option_change(mcm)
if mcm then
KEY = ui_mcm.get("rax_qrs/keybind") or KEY
mode = ui_mcm.get("rax_qrs/mode")
modifier = ui_mcm.get("rax_qrs/modifier")
end
end
function on_key_hold(key)
if mcm_keybinds and (key == KEY) and (mode == 2) and ui_mcm.get_mod_key(modifier) and ui_mcm.key_hold("rax_qrs",key, 5) then
use_quickrs()
end
end
function on_key_press(key)
if (key == KEY) then
if (not mcm_keybinds) then
use_quickrs()
return
end
--[[
if (mode == 0) and ui_mcm.get_mod_key(modifier) and not ui_mcm.double_tap("rax_qrs",key, true) then
use_quickrs()
return
end
--]]
if mode == 0 then
ui_mcm.simple_press("rax_qrs", key, use_quickrs)
end
if (mode == 1) and ui_mcm.get_mod_key(modifier) and ui_mcm.double_tap("rax_qrs",key) then
use_quickrs()
return
end
end
end
function on_game_start()
RegisterScriptCallback("on_option_change",on_option_change)
RegisterScriptCallback("on_key_hold",on_key_hold)
RegisterScriptCallback("on_key_press",on_key_press)
on_option_change(mcm_keybinds)--
end
function use_quickrs()
release = db.actor:object("itm_actor_backpack")
if release then
db.actor:eat(release)
end
end