I started in programming, I did some switch and now I try to operate a stepper motor to engine RPM but I have some worries code for FS2020
message error :
ERROR - error in dataref callback: logic.lua:11: attempt to index a number value (local 'rpm')
Can you help me?
Code: Select all
stepper_rpm = hw_stepper_motor_add("Engine RPM", "4WIRE_4STEP", 945, 30) -- Initialization starting, rotate clockwise for 3 seconds hw_stepper_motor_position(stepper_rpm, nil, "ENDLESS_CLOCKWISE") timer_start(3000, function(count) hw_stepper_motor_calibrate(stepper_rpm, 0.0) hw_stepper_motor_position(stepper_rpm, 0.0) local function PT_rpm_FSX(rpm) engine_rpm = var_cap(rpm, 0, 3500) -- The stepper motor position is set as a value from 0 to 1, so we have to convert the RPM to a position. -- Therefore we divide 1 by 3500, this is then multiplied with the current RPM. hw_stepper_motor_position(stepper_rpm, 1 / 3500 * engine_rpm) end fs2020_variable_subscribe("PROP RPM:1", "RPM", PT_rpm_FSX) end)