mkafrin / PolyZone

PolyZone is a FiveM mod to define zones of different shapes and test whether a point is inside or outside of the zone
MIT License
202 stars 193 forks source link

tweak: redundancy checks for control input #53

Closed Spudgun closed 2 years ago

Spudgun commented 2 years ago

Enables key binds for poly manipulation regardless if a key is enabled or disabled.

A lot of no-clips disable input of all types, making the IsControlJustPressed not trigger. Essentially just makes this script compatible with a lot of other scripts that disable input of certain types.

Ekinoxx0 commented 2 years ago

From my testing IsDisabledControlPressed also return valid data even if the control is not disabled, it seems to me that IsControlKeyJustPressed is redundant from just using the Disable native.

mkafrin commented 2 years ago

Hmm, @Spudgun can you check if what Ekinoxx said is accurate, and if so, update the PR?

Also, the difference between "ControlPressed" and "ControlJustPressed" in the resource is intentional. In some cases, things should only work on press and others (like modifiers) should support pressing and holding. Combining those two is fundamentally changing how the controls work and I don't think that's good. If you had a particular reason for doing this, please detail that reason so I can better understand.

Spudgun commented 2 years ago

Hmm, @Spudgun can you check if what Ekinoxx said is accurate, and if so, update the PR?

Also, the difference between "ControlPressed" and "ControlJustPressed" in the resource is intentional. In some cases, things should only work on press and others (like modifiers) should support pressing and holding. Combining those two is fundamentally changing how the controls work and I don't think that's good. If you had a particular reason for doing this, please detail that reason so I can better understand.

So I've just had a play around with the control enabling/disabling. I can confirm that what @Ekinoxx0 said is correct. If a control key is enabled or disabled right before the check that of IsDisabledControlPressed or IsControlPressed etc it will then trigger even if the control is being disabled/enabled in another script.

This is then making my implementation of IsControlKeyJustPressed function redundant.

In saying all of the above, I have updated my PR to ensure that functionality is still possible in the circumstances another script is disabling/enabling the control key we're testing for. I have also reverted the JustPressed and Press changes as I didn't think through the intended use case scenario for those. It's quite fundamental to how the script works, as you said 🙂

Spudgun commented 2 years ago

All good, mate!

Happy to help contribute to such a useful tool!