Servers by jDrones

Is there a cs.variable for lua?

I am trying to create a while loop similar to the python command.

while (cs.ch9in < 1400) do

however since this is lua cs.ch9in will not work, I am essentially trying to have it run when ch9’s value is greater than 1400pwm

rc:get_pwm(whatever_channel) > 1400 would get you most of the way there. I would tend not to use while loops as those will cause the script to be killed for taking too long if the while loop gets hung up waiting for the conditional to be met. You can check that the RC input is low every time the update function is called and make the callback time shorter (100 ms?).

So something similar to

function update()
    if rc:get_pwm(9) > 1400 then  
        -- do whatever here
    return update, 100

return update(), 500
1 Like
Servers by jDrones