1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

ui_label and make_persistent

Discussion in 'Scripting Workshop' started by Jesse01, Nov 7, 2021.

  1. corbo-billy

    corbo-billy NI Product Owner

    Messages:
    652
    This is what I thought because we don't even know what this slider is for ($fx01) .
     
  2. Jesse01

    Jesse01 New Member

    Messages:
    14
    it's gonna be for phaser feedback
     
  3. corbo-billy

    corbo-billy NI Product Owner

    Messages:
    652
    Well, you have to add it to the fx01 callback .

    And for such a destination for this slider (phaser feedback), it seems strange to declare it like this: declare ui_slider $ fx01 (0, 20) _
    Instead, you should: declare ui_slider $ fx01 (0, 1000000)
     
  4. Jesse01

    Jesse01 New Member

    Messages:
    14
    ok i will do that but the question is how can i keep the values of ui_label saved when i save the projact on my daw?
     
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    This was already explained...
     
  6. Jesse01

    Jesse01 New Member

    Messages:
    14
    Can you give me an example please in my code :
    on init
    make_perfview
    set_ui_height_px(200)

    declare ui_slider $fx01(0, 20)
    hide_part($fx01, $HIDE_PART_BG .or. $HIDE_PART_MOD_LIGHT .or. $HIDE_PART_TITLE .or. $HIDE_PART_VALUE)
    set_control_par_str(get_ui_id($fx01), $CONTROL_PAR_PICTURE,"fx_img")
    move_control_px($fx01, 50, 100)
    set_control_par(get_ui_id($fx01), $CONTROL_PAR_MOUSE_BEHAVIOUR, -1000)
    $fx01 := 500000
    make_persistent($fx01)

    declare ui_label $Percent(0, 20)
    set_text ($Percent,"")
    move_control_px($Percent, 100, 100)
    set_control_par_str(get_ui_id($Percent), $CONTROL_PAR_PICTURE, "Percent_img")

    end on
    on ui_control ($fx01)
    set_control_par(get_ui_id($Percent),$CONTROL_PAR_PICTURE_STATE ,$fx01)
    end on
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Code:
    on init
        make_perfview
        set_ui_height_px(200)
    
        declare ui_slider $fx01 (0, 1000000)
        make_persistent($fx01)
    
        declare ui_label $Percent (1, 1)
        set_text($Percent, "")
        set_control_par_str(get_ui_id($Percent), $CONTROL_PAR_PICTURE, "Percent_img")
    end on
    
    on persistence_changed
        set_control_par(get_ui_id($Percent), $CONTROL_PAR_PICTURE_STATE, $fx01 / 52631)
    end on
    
    on ui_control ($fx01)
        set_control_par(get_ui_id($Percent), $CONTROL_PAR_PICTURE_STATE, $fx01 / 52631)
    end on
    
    As I said, it's a callback like any other. This really isn't that difficult.
     
    • Like Like x 1
  8. Jesse01

    Jesse01 New Member

    Messages:
    14
    Omg:confused:.. I think i just found out why this wasn't working for me all this time, because i'm using an older version of kontakt 5 and probably not compatible with on persistence_changed... Thank you so much for your help sir!
     
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Oh! You need Kontakt 5.4.0 at minimum for persistence_changed callback, indeed.
     
  10. corbo-billy

    corbo-billy NI Product Owner

    Messages:
    652