When a new instrument is created, on the "Amplifier" section, there's already a AHDSR mod (with name "ENV_AHDSR_VOLUME"). On the "Group InsertFX" section, I do insert a "2-pole LP" (LP 2) filter and then add a AHDSR mod to it, which has as name "ENV_AHDSR_CUTOFF".
Now I load the first example for find_mod that appear on the KSP manual reference:
Code: Select all
on init
declare ui_knob $Intensity (-100,100,1)
declare $mod_idx
$mod_idx := find_mod(0,"FILTER_ENV")
declare $target_idx
$target_idx := find_target(0,$mod_idx,"ENV_AHDSR_CUTOFF")
end on
on ui_control ($Intensity)
if ($Intensity < 0)
set_engine_par ($MOD_TARGET_INVERT_SOURCE, 1,0,$mod_idx,$target_idx)
else
set_engine_par ($MOD_TARGET_INVERT_SOURCE, 0,0,$mod_idx,$target_idx)
end if
set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY, abs($Intensity*10000),0,$mod_idx,$target_idx)
end on
It shows that the name thing doesn't work at all with "internal mods", but only with "external" (PB,VEL, etc.).
With internal ones, it sort them a number as they are added, like slots. The mod that is at the amplifer section is the number 0, and the new one is the 1. If its created another one on one of those sections, or another on the Source section, would have the number 2 and so on. Replacing "$mod_idx, $target_idx" with "number,-1" with give absolute control.
Example :
Code: Select all
on init
declare ui_knob $Intensity (-100,100,1)
end on
on ui_control ($Intensity)
if ($Intensity < 0)
set_engine_par ($MOD_TARGET_INVERT_SOURCE, 1,0, 1,-1)
else
set_engine_par ($MOD_TARGET_INVERT_SOURCE, 0,0, 1,-1)
end if
set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY, abs($Intensity*10000),0, 1,-1)
end on
It can be applied on $ENGINE_PAR_MOD_TARGET_INTENSITY, $ENGINE_PAR_INTMOD_INTENSITY or $ENGINE_PAR_EXTMOD_INTENSITY (which is a parameter for use with external modulators that isn't mentioned on the KSP reference manual at all).
The thing here, is that using the $ENGINE_PAR_INTMOD_INTENSITY and $ENGINE_PAR_EXTMOD_INTENSITY you don't need the create the conditional
Code: Select all
if ($Intensity < 0)...
I would really loved to see the internal mods work with the names assigned, but for internal modulators, its totally useless as that example on the manual. At least its mentioned on the newer versions the paramenter $ENGINE_PAR_INTMOD_TYPE (which I find out by myself that existing a $ENGINE_PAR_INTMOD_SUBTYPE there should be a TYPE parameter!), because it doesn't appear at all on the K4's KSP pdf. With that, and $INTMOD_TYPE_NONE is possible to retrieve if internal mods are or not inserted.
That's all for now.
Cheers