Flohhhhh / ultimate-lighting-controller

An all-in-one lighting controller for Non-ELS vehicles in FiveM
https://docs.dwnstr.com/ulc/overview
Other
42 stars 14 forks source link

Changing multiple buttons at once is unreliable in JS #31

Open Flohhhhh opened 3 months ago

Flohhhhh commented 3 months ago

When making multiple function calls in the JS to update a button state, since all buttons are stored within one state, the states get all tangled and the end result is buttons not matching their extra state.

Flohhhhh commented 3 months ago

I improved this issue by making the ULC:SetStage function gather all button changes that occur in it's execution, and send a single event to update all buttons at the end.

This removes any repeated calls to the JS in cases of recursion, but unfortunately, with any feature where the function is still called multiple times for example when 4 extras are set as brake extras (or any other time where multiple extras that are also buttons are changing at the same time) the issue still exists.

It should be much less noticeable now, and doesn't effect the gameplay or functionality at all.

The further changes needed for this have to either be to the method in handling button state in JS to make each button maintain independent state, or continue work in LUA by gathering all changes in each feature into one update as before. Though this is too much work for me right now.

Maybe we should just call a function to update the UI manually from within each feature (like park, brake, buttons etc.) so we can manually decide when to send the UI update?

Flohhhhh commented 3 months ago

For some reason the first and last button are always correct, but any between those seem to usually not work, but sometimes do