UI button – parameters

Viewing 4 reply threads
  • Author
    Posts
    • #3443
      Szabadi Gergely
      Participant

      Hi there,

      I have a problem, and I would be grateful for some help. I would like to control am integer parameter with a UI button.

      For example

      I have an integer parameter called: n
      button id=1
      parameter script:

      if glob_ui_button_id=1 then
      parameters n=n+1
      endif

      ——-

      G. Szabadi

    • #3444
      Ben Cohen
      Participant

      Hi

      Is the problem that parameter script is running more than once – therefore “n = n + 1” is not working as expected?

      If so you have two possible solutions
      1. Under details ‘Compatibility Options’ check the box ‘Run parameter script only once’

      2. You could also use “APPLICATION_QUERY” to also make sure it only runs once

      n = APPLICATION_QUERY (“parameter_script”, “firstoccasion_in_progress”, isFirstRun)
      if isFirstRun then
      // do stuff
      endif

    • #3445
      Szabadi Gergely
      Participant

      Hi!

      Thanks for the respond. Sorry it doesn’t work for me. If I use the “application_query” then I get a missing comma error.
      But I would like to show, what I am really into. I attached the gsm. with a UI picture, what I am working.

      So…

      I have a “n” (1-10) looped 3D obejct.
      I have 10 surface parameter. I control them with array.
      I would like that the user can control with UI BUTTONS (+, -) the n parameter so when I push “-” button it delete a row, but the essence is that I don’t want to delete the row, I only want that every material parameters value would jump one place + or -.

      I hope I describe my problem well. I am so sorry, I get that it is not so much a forum theme rather my own defect that I cannot understand.

      Thanks for any help

      G. Szabadi

    • #3449
      Ben Cohen
      Participant

      Add this to your code

      parameters script

      if GLOB_UI_BUTTON_ID <> 0 then
      parameters n = n + GLOB_UI_BUTTON_ID
      GLOB_UI_BUTTON_ID = 0
      endif

      interface script

      for i=1 to n
      ui_button ui_function, “-“, _x2+200, _y, 20, 20, -1
      ui_button ui_function, “+”, _x2+220, _y, 20, 20, 1
      ui_style 0, 0 :ui_outfield “mat”+str(i, 1, 0) ,_x, _y :ui_style 0, 0 :ui_infield vari_mat_[i], _x2, _y-5, _sx-200, _sy :_y=_y+_d
      next i

      HTH 🙂

      Ben

    • #3450
      Szabadi Gergely
      Participant

      Dear Ben!

      Yes it helped, thank you. But I still cannot understand how can I change values of an array in this example.
      I tried this:

      PARAMETER SCRIPT:

      for i=1 to n
      if GLOB_UI_BUTTON_ID <> 0 then
      if GLOB_UI_BUTTON_ID<0 then
      parameters n = n – 1
      parameters vari_mat[i]= tempTexts[i-1]
      endif
      if GLOB_UI_BUTTON_ID>0 then
      parameters n = n + 1
      parameters vari_mat[i]= tempTexts[i+1]
      endif
      GLOB_UI_BUTTON_ID = 0
      endif
      next i

      BASIC SCRIPT:

      dim vari_mat[]
      vari_mat[1]=mat1
      vari_mat[2]=mat2
      vari_mat[3]=mat3
      vari_mat[4]=mat4
      vari_mat[5]=mat5
      vari_mat[6]=mat6
      vari_mat[7]=mat7
      vari_mat[8]=mat8
      vari_mat[9]=mat9
      vari_mat[10]=mat10

      dim vari_mat_[]
      vari_mat_[1]=”mat1″
      vari_mat_[2]=”mat2″
      vari_mat_[3]=”mat3″
      vari_mat_[4]=”mat4″
      vari_mat_[5]=”mat5″
      vari_mat_[6]=”mat6″
      vari_mat_[7]=”mat7″
      vari_mat_[8]=”mat8″
      vari_mat_[9]=”mat9″
      vari_mat_[10]=”mat10″

      dim tempTexts[]
      tempTexts[1]= vari_mat[1]
      tempTexts[2]= vari_mat[2]
      tempTexts[3]= vari_mat[3]
      tempTexts[4]= vari_mat[4]
      tempTexts[5]= vari_mat[5]
      tempTexts[6]= vari_mat[6]
      tempTexts[7]= vari_mat[7]
      tempTexts[8]= vari_mat[8]
      tempTexts[9]= vari_mat[9]
      tempTexts[10]= vari_mat[10]

      dim tempTexts_[]
      tempTexts_[1]= vari_mat_[1]
      tempTexts_[2]= vari_mat_[2]
      tempTexts_[3]= vari_mat_[3]
      tempTexts_[4]= vari_mat_[4]
      tempTexts_[5]= vari_mat_[5]
      tempTexts_[6]= vari_mat_[6]
      tempTexts_[7]= vari_mat_[7]
      tempTexts_[8]= vari_mat_[8]
      tempTexts_[9]= vari_mat_[9]
      tempTexts_[10]= vari_mat_[10]

      I just don’t figure out, how can I change of the values of an array.
      ThX

      G. Szabadi

Viewing 4 reply threads
  • The forum ‘Graphical UI and parameters list’ is closed to new topics and replies.