Mach Discussion > Mach4 General Discussion
I want to limit the RRO value to 0 and 100
(1/1)
gravie:
I use the encoder inputs from Pokeys for FRO and RRO control. but the RRO value goes below and over 100%. at the FRO value it fits, can I fix it with a spript, which I insert into the screen script?
AI spits out the following.
-- Function to limit the Rapid Override (RRO) value
function LimitRRO()
-- Read the current Rapid Override (RRO) value
local rro_value = mc.mcCntlGetRapidOverride(0)
-- Limit the RRO value to between 0% and 100%
if rro_value < 0 then
rro_value = 0
elseif rro_value > 100 then
rro_value = 100
end
-- Set the limited RRO value
mc.mcCntlSetRapidOverride(0, rro_value)
-- Optional: Display the current RRO value in the status bar
mc.mcCntlSetStatusText("Rapid Override (RRO): " .. tostring(rro_value) .. "%")
end
-- This function is already called every 50ms by the ScreenScript
LimitRRO()
Explanation:
mc.mcCntlGetRapidOverride(0): Retrieves the current Rapid Override value for axis 0 (if you are using a different axis, replace 0 with the appropriate axis number).
mc.mcCntlSetRapidOverride(0, rro_value): Sets the Rapid Override value to the bounded value.
mc.mcCntlSetStatusText(): Displays the current Rapid Override value in the status bar, which is useful for debugging and visual confirmation.
Steps to Integrate:
Open the Mach4 ScreenScript Editor.
Paste the above Lua code into your existing ScreenScript.
Save the script and reload it in Mach4.
Since the ScreenScript runs periodically (every 50ms), it will check and limit the RRO value automatically.
What happens:
The script checks the current RRO value.
If the value is outside the range of 0% to 100%, it is clamped to the nearest valid value (0% or 100%).
The clamped value is then set again to ensure the RRO remains within the valid range.
If you encounter any further issues or have more questions, feel free to ask!
gravie:
I just found out that it's much easier. You only have to set a min and max value in the screen.
gravie:
The min max value is in the fro part, but in the rro it is empty.
Navigation
[0] Message Index
Go to full version