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

Solved set skin offset persistence

Discussion in 'Scripting Workshop' started by Reylon, Oct 27, 2021.

  1. Reylon

    Reylon NI Product Owner

    Messages:
    124
    Hi guys,

    I was trying to make persistent the wallpaper when it moves from A image to B image but not sure what should I do here. Any help is highly appreciated.
    Code:
    on init
      make_perfview
      set_ui_height_px(540)
      set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"DifferentBackground")
      declare $count
      declare ui_button $switch_wp
      set_control_par_str(get_ui_id($switch_wp),$CONTROL_PAR_PICTURE,"btn_1")
      set_control_par_str(get_ui_id($switch_wp),$CONTROL_PAR_TEXT,"")
      set_control_par(get_ui_id($switch_wp),$CONTROL_PAR_WIDTH,40)
      set_control_par(get_ui_id($switch_wp),$CONTROL_PAR_HEIGHT,40)
      set_control_par(get_ui_id($switch_wp),$CONTROL_PAR_POS_X,296)
      set_control_par(get_ui_id($switch_wp),$CONTROL_PAR_POS_Y,430)
    end on
    
    on persistence_changed
      if ($switch_wp=1)
        $count := 0
        while ($count<1150)
          set_skin_offset($count)
          wait(5000)
          inc($count)
        end while
      else
        set_skin_offset(0)
      end if
    end on
     
    on ui_control($switch_wp)
      if ($switch_wp=1)
        $count := 0
        while ($count<1150)
          set_skin_offset($count)
          wait(5000)
          inc($count)
        end while
      else
        set_skin_offset(0)
      end if
    end on
    
    EDIT: The on persistence part does the trick but I'm not sure if its the right way of doing it.
     
    Last edited: Oct 27, 2021
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Don't do that wait in persistence_changed. But that's the way to go yes.

    set_skin_offset(1150 * $switch_wp)

    Then just make $switch_wp persistent.
     
  3. Reylon

    Reylon NI Product Owner

    Messages:
    124
    Thanks ED,

    hmm okay. Im thinking about the on persistence part will include a lot of different "end ifs" and maybe they will not work properly.
    Code:
    on persistence_changed
      if ($switch_wp=1)
        $count := 0
        while ($count<1150)
          set_skin_offset($count)
          wait(5000)
          inc($count)
        end while
      else
        set_skin_offset(0)
      end if
    
      if ($switch_Db=1)
        $count := 0
        while ($count<1150)
          set_skin_offset($count)
          wait(5000)
          inc($count)
        end while
      else
        set_skin_offset(0)
      end if
    end on
    
    
    something like this i.e. Don't know if this is ok
     
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You don't need this at all. All you need is just one set_skin_offset() in there. Please don't do that animation in persistence_changed, it will be annoying to people.
     
  5. Reylon

    Reylon NI Product Owner

    Messages:
    124
    Haha no no, it's just for testing purpose. Thanks Ed!