Claud9
Active Member
Hello everyone,
I'm trying to modify a script I found on KSP manual.
It's a script that animates a single knob back an forth at a fixed speed.
I'm trying to add a second knob and animate it at a different speed so that at the same time they are both moving but at different speed rates.
It's the first time I'm using the "on listener" call back.
I tried this solution but is not working and only the first knob is moving. I did also some experiment with "change_listener_par" but is not working. Is something possible to move both at the same time with different speed? Thanks in advance for any help!
I'm trying to modify a script I found on KSP manual.
It's a script that animates a single knob back an forth at a fixed speed.
I'm trying to add a second knob and animate it at a different speed so that at the same time they are both moving but at different speed rates.
It's the first time I'm using the "on listener" call back.
I tried this solution but is not working and only the first knob is moving. I did also some experiment with "change_listener_par" but is not working. Is something possible to move both at the same time with different speed? Thanks in advance for any help!
Code:
on init
declare ui_knob $test1 (0,99,1)
declare $direction_test1
declare $tick_counter_test1
declare ui_knob $test2 (0,99,1)
declare $direction_test2
declare $tick_counter_test2
set_listener($NI_SIGNAL_TIMER_MS,7000)
end on
on listener
if($NI_SIGNAL_TYPE = $NI_SIGNAL_TIMER_MS)
if ($direction_test1 = 0)
inc($tick_counter_test1)
else
dec($tick_counter_test1)
end if
$test1 := $tick_counter_test1
if ($tick_counter_test1 = 99)
$direction_test1 := 1
end if
if ($tick_counter_test1 = 0)
$direction_test1 := 0
end if
end if
while ($NI_SIGNAL_TIMER_MS=2000)
if ($NI_SIGNAL_TYPE = $NI_SIGNAL_TIMER_MS)
if ($direction_test2 = 0)
inc($tick_counter_test2)
else
dec($tick_counter_test2)
end if
$test1 := $tick_counter_test2
if ($tick_counter_test2 = 99)
$direction_test2 := 1
end if
if ($tick_counter_test2 = 0)
$direction_test2 := 0
end if
end if
end while
end on