diff --git a/msu/systems/keybinds/keybind_sq.nut b/msu/systems/keybinds/keybind_sq.nut index f4861ec9c..96377692c 100644 --- a/msu/systems/keybinds/keybind_sq.nut +++ b/msu/systems/keybinds/keybind_sq.nut @@ -3,6 +3,9 @@ Function = null; State = null; KeyState = null; + CallContinuously = false; + TriggerDelay = null; + NextCallTime = null; BypassInputDenied = false; constructor( _modID, _id, _keyCombinations, _state, _function, _name = null, _keyState = null) @@ -23,6 +26,13 @@ return this; } + function setCallContinuously(_bool, _triggerDelay = null) + { + this.CallContinuously = _bool; + this.TriggerDelay = _triggerDelay; + return this; + } + function getState() { return this.State; @@ -33,8 +43,15 @@ return (this.State & _state) != 0; } + function checkContinuousCall(_keyState) + { + return ((this.KeyState & ::MSU.Key.KeyState.Continuous) != 0) && ((this.NextCallTime == null) || (::Time.getRealTimeF() > this.NextCallTime)); + } + function callOnKeyState( _keyState ) { + if (this.CallContinuously && _keyState == ::MSU.Key.KeyState.Continuous) + return this.checkContinuousCall(_keyState) return (_keyState & this.KeyState) != 0; } @@ -50,7 +67,10 @@ function call( _environment ) { - return this.Function.call(_environment); + local ret = this.Function.call(_environment); + if (ret && this.CallContinuously && this.TriggerDelay != null) + this.NextCallTime = ::Time.getRealTimeF() + this.TriggerDelay; + return ret; } function tostring() diff --git a/msu/vanilla_mod/vanilla_keybinds.nut b/msu/vanilla_mod/vanilla_keybinds.nut index c4da01083..37719a4a8 100644 --- a/msu/vanilla_mod/vanilla_keybinds.nut +++ b/msu/vanilla_mod/vanilla_keybinds.nut @@ -66,7 +66,7 @@ local function isCampfireScreen() { if (!this.m.MenuStack.hasBacksteps() || this.m.TacticalMenuScreen.isVisible()) { - if (this.toggleMenuScreen()) + if (!this.m.TacticalMenuScreen.isAnimating() && this.toggleMenuScreen()) { return true; }