What's new

On init declarations ignore if conditions

angeruroth

Active Member
This code should explain the issue:

Code:
on init
    set_script_title("Main Script")
    set_ui_height_px(194)
    make_perfview

    declare $is_B := 0
    $is_B := find_group("# Is B #")

    if($is_B > 0)
        set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"Background2")
    else
        set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"Background")

        declare ui_slider $ratio (0,49)
            set_control_par_str(get_ui_id($ratio),  $CONTROL_PAR_PICTURE, "VSlider")

        .... MORE DECLARATIONS AND CODE ....

    end if
end on
find_group works as expected, and the picture selection also works, but then Kontakt declares everything (I see knobs and labels).

Is there a way to declare different things using conditions? Or a workaround?

Thanks!
 
OP
angeruroth

angeruroth

Active Member
Can't use preprocessor directives because the prepro commands are executed no matter the rest of the code (as expected really).
Example:
Code:
declare $is_B := 0
    $is_B := find_group("# Is B #")
    if($is_B > 0)
        SET_CONDITION(is_b)
    else
        RESET_CONDITION(is_b)
    end if
Both SET_CONDITION and RESET_CONDITION are always executed.

Any ideas?

I'm just trying to use the same script file in two different instruments.
 

geronimo

Active Member
I don't know if I understood your problem correctly?

Only one wallpaper can be loaded by KONTAKT.
For produces the illusion of having different background pictures, you must have a single picture.
To change the wallpaper, it's easier to work with the following command:
set_skin_offset (value in pixel)
 

willbedford

Composer/Programmer
Variables and conditions are global/static. You can't choose which variables/UI objects to declare based on 'if' statements. You'll need to declare everything, then hide the controls you don't want to see.

SET_CONDITION and USE_CODE_IF are useful if you want to use a single master script to compile different versions for different instruments. The code is included or excluded at compile time, so there's no way to update the conditions dynamically.
 
Top Bottom