HISE Logo Forum
    • Categories
    • Register
    • Login

    Randomizer on 3 Grouped buttons, How?

    Scheduled Pinned Locked Moved Scripting
    97 Posts 4 Posters 4.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NatanN
      Natan @d.healey
      last edited by

      @d-healey
      I'm still here:

      Content.makeFrontInterface(600, 500);
      
      const randomValue = Math.randInt(0, 3);
      Console.print(randomValue);
      
      
      const var Btns = [Content.getComponent("Button3"),
                        Content.getComponent("Button2"),
                        Content.getComponent("Button1")];
      
                        
                        
      inline function onRandITControl(component, value)
      {
          
      
      };
      
      Content.getComponent("RandIT").setControlCallback(onRandITControl);
      
      1 Reply Last reply Reply Quote 1
      • d.healeyD
        d.healey
        last edited by

        Perfect. Now move the randomValue inside the button's callback function, you'll need to use a local variable instead of a const.

        You can use the random value as the Btns array index to turn on one of the buttons.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        NatanN 1 Reply Last reply Reply Quote 0
        • NatanN
          Natan @d.healey
          last edited by

          @d-healey is this correct?

          Content.makeFrontInterface(600, 500);
          
          const randomValue = Math.randInt(0, 3);
          Console.print(randomValue);
          
          
          const var Btns = [Content.getComponent("Button3"),
                            Content.getComponent("Button2"),
                            Content.getComponent("Button1")];
          
                            
          
          inline function onRandITControl(component, value)
          {
              local idx = buttons.indexOf(component);
          
              
          };
          
          Content.getComponent("RandIT").setControlCallback(onRandITControl);
          
          
          
          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @Natan
            last edited by

            @Natan Not even close :p

            Move the randomValue stuff inside the button's callback. You'll need to use a local variable instead of a const. You can delete the Console.print() we don't need that now.

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            NatanN 1 Reply Last reply Reply Quote 0
            • NatanN
              Natan @d.healey
              last edited by

              @d-healey Lol

              Content.makeFrontInterface(600, 500);
              
              
              
              
              const var Btns = [Content.getComponent("Button3"),
                                Content.getComponent("Button2"),
                                Content.getComponent("Button1")];
              
                                
              
              inline function onRandITControl(component, value)
              {
              local randomValue = Math.randInt(0, 3);
              Console.print(randomValue);    
              
              };
              
              Content.getComponent("RandIT").setControlCallback(onRandITControl);
              
              
              1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey
                last edited by

                Now we're getting somewhere!

                We don't need Console.print() any more, that was just for testing the random value which we know works now.

                Do you know how to turn a button on or off by changing its value?

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                NatanN 1 Reply Last reply Reply Quote 0
                • NatanN
                  Natan @d.healey
                  last edited by

                  @d-healey Yeah, I Guess I'm So Close :)
                  Wait Sir

                  1 Reply Last reply Reply Quote 1
                  • NatanN
                    Natan
                    last edited by

                    @d-healey Haha, That Was A Real Challenge, And Yep This is it :)

                    Content.makeFrontInterface(600, 500);
                    
                    
                    const var Btns = [Content.getComponent("Button3"),
                                      Content.getComponent("Button2"),
                                      Content.getComponent("Button1")];
                    
                                      
                    inline function onRandITControl(component, value)
                    {
                    
                        local randomValue = Math.randInt(0, 3);
                        Console.print(randomValue);   
                    
                        if (value == 1)
                        {
                           Btns[randomValue].setValue(1);
                        }      
                    };
                    
                    Content.getComponent("RandIT").setControlCallback(onRandITControl);
                    
                    1 Reply Last reply Reply Quote 1
                    • d.healeyD
                      d.healey
                      last edited by

                      Yeah looks like you got it! Well done!

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      NatanN 1 Reply Last reply Reply Quote 1
                      • NatanN
                        Natan @d.healey
                        last edited by

                        @d-healey :) Haha Yessir :)
                        Thanks You Dear David, True Legend :)

                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @Natan
                          last edited by

                          @Natan You did it, not me. I just nudged you :p

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          NatanN DanHD 2 Replies Last reply Reply Quote 3
                          • NatanN
                            Natan @d.healey
                            last edited by

                            @d-healey Thanks for the help, You're a great guy :)

                            1 Reply Last reply Reply Quote 0
                            • DanHD
                              DanH @d.healey
                              last edited by

                              @d-healey Just trying this out. What if I wanted only one of the buttons to be on at a time? Like a radio group. I can get them to go on and off randomly, but not like a radio group...

                              DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                              https://dhplugins.com/ | https://dcbreaks.com/
                              London, UK

                              d.healeyD 1 Reply Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @DanH
                                last edited by

                                @DanH Check out my tabbed interfaces video.

                                Libre Wave - Freedom respecting instruments and effects
                                My Patreon - HISE tutorials
                                YouTube Channel - Public HISE tutorials

                                DanHD 2 Replies Last reply Reply Quote 0
                                • DanHD
                                  DanH @d.healey
                                  last edited by

                                  @d-healey ah yes of course :) I'm already using it!

                                  DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                  https://dhplugins.com/ | https://dcbreaks.com/
                                  London, UK

                                  1 Reply Last reply Reply Quote 1
                                  • DanHD
                                    DanH @d.healey
                                    last edited by

                                    @d-healey Ok I am failing miserably at trying to combine these two scripts 😆

                                    DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                    https://dhplugins.com/ | https://dcbreaks.com/
                                    London, UK

                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @DanH
                                      last edited by

                                      @DanH Post a minimal snippet

                                      Libre Wave - Freedom respecting instruments and effects
                                      My Patreon - HISE tutorials
                                      YouTube Channel - Public HISE tutorials

                                      DanHD 1 Reply Last reply Reply Quote 0
                                      • DanHD
                                        DanH @d.healey
                                        last edited by DanH

                                        @d-healey

                                        HiseSnippet 1196.3ocuW8tahbCD2aR1SGaKU8j5CfU9vIPWJAR3tVI5oF96ITCDDPhZ0oSQlcMfU10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LnCF8E9knh6QAcZ6FDIQUpMxcAtvYTeISEcLZPuD5gIrvaFyFzfKjhYZ+Yzc.36GgG8JPMieG1sEpONF9fxIPXV0OwwThOeYC.OEydvZl82ddL6gqY1+34wrkWyr6X7HL6K9minWsJZ9KsNZQbnsxQoZcVPGgGXah+Bcp5c6uB5xS3L2kHucqep9ciD.WzuUOVp9n3AL4hj8C+utevTuR+Ho6qL6wj1SSmuakBeg7++q4aT20YMaNdL0VFS1cLa8iOusRmJU5KlKY7IP2U9LUpX24dCf+rgMEXBmScUOFCIDJn54EUyUdlATtidxeAiHgkTyMhDVZoPjGw1Wbtc3CRp92eodEfSb8eiIiYG0b7p2XMMKVnHxCxQO21V4J9Zf6oi4fM.yga.lxa.l2tAXd2Ff4a1.Le6ChQ87P04RgW30DXgdM0EDLLZpe+PmQh9abY+UfD
                                        

                                        :folded_hands_medium-light_skin_tone:

                                        PS - Just looking back at the tabbed interface script and realising that I actually understand what is does, as opposed to not having a clue a few weeks back :face_with_tears_of_joy: Thanks for the help on that score....

                                        DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                        https://dhplugins.com/ | https://dcbreaks.com/
                                        London, UK

                                        LindonL 1 Reply Last reply Reply Quote 1
                                        • LindonL
                                          Lindon @DanH
                                          last edited by

                                          @DanH said in Randomizer on 3 Grouped buttons, How?:

                                          HiseSnippet 1196.3ocuW8tahbCD2aR1SGaKU8j5CfU9vIPWJAR3tVI5oF96ITCDDPhZ0oSQlcMfU10FsqIMnnH0OUo9BzGo97z2f1wdWX2P1jlPSq+Bq8L+F+yyL1yPOegMMHP3iLxLbwLJx3yMGrfKmVeJgwQsafLdoY+pcabRGTsEyHAATGjgw1ePI0HyNH83O+9ZDWB2lFuDBclfYSOl4wjwq16nef451h3PGx7Rnc4iZaK30Eth4.S11rHZFw9BxDZWhRssLQFunoCSJ7GHIRZ.xXmZBmEClJ9Ydn9mwBXibopIkPC.CEtbKgqihwpUQ0mxbc5s7DGf.qzK97uc34+qL6vbXqVO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X24dCf+rgMEXBmScUOFCIDJn54EUyUdlATtidxeAiHgkTyMhDVZoPjGw1Wbtc3CRp92eodEfSb8eiIiYG0b7p2XMMKVnHxCxQO21V4J9Zf6oi4fM.yga.lxa.l2tAXd2Ff4a1.Le6ChQ87P04RgW30DXgdM0EDLLZpe+PmQh9abY+UfD

                                          is this what you mean?

                                          HiseSnippet 1221.3ocsW8tahaDDecRbzgaopmTe.VkObxnKk.IbWqD8TC+8DpGDDPhZ0onnE6EXUL6hrWRCJJR8QoOJ2iTeCZmcsw1IAxkidweHgcl423e6Lyty3t9BGZPfvGYjYvhYTjw2Z1eAWNo1DBiiZUGY7BydU5T+j1npKlQBBntHCiseuRqQlcP5m+4WqR7HbGZhHD5LAyg9A1TlLQZ2i+MlmWShKc.aZJqKcbKGAulvSLGXx1lEPyHNWRFS6PTlskIxX2FtLovuujHoAHicpJbWzeh3O4g1eFKfMzipVTD0GbTn3lBOWEiURQ0lv7b6tbGGf.uzMY+uc39+GLaybYwxShCeuVANAQ53gwVOF8JlldEd5zyHE81IjduzruiOalLQihaeiYKtj5Oh.ofzzJzVzV+soYMAXAWleJ4RZSeXQLB62Vnv932TnPtxYsxZc.7fa+G3pmNXvIc5is4PNvE6S3tho3QBeLWf8oj.AOWVKHsEHwWQ7wCk7dg17N7GW91FSk0DSmI3vB68BKjJtWt8yZgW8yiA7vME3QaJvR6k67jfRmJCp.AjPUQwGkRF2iwo3Qy4NRlfiE5.QqAJO6K7rcV518g.k2bZNqarzrwS3P7hhrmoz.gt1D4j7JQP9wFxKGkqrUDMCDdz7y7YfhTXxUFzF5O1Hr8Ug94c3h4zxtY49NN+7wTfOOe.Up+kcQU5+ws0YBgOl5ZGQoaCMVEBT+251xVVqIZpiG6kS81hhJ0HddCgC412KZkpHbPkpUaTG2pyfF8ZVoVCb+Z8Z0cfReRYWmSaeAXXeHzURCUUgZyfkEJiY3eI1.X0qeMTwdSHaS1hryWEsB2qCHCUD51PNAqvCmKkPN1Ixt3r9CKCh8vCK.hYwAG7dpDy3tzqwhQXGOlykvgsvWR1TEIL2qgsTLoyqgbxnDWmJ6gW56Ahwi8nQdKHT58COItzixGKmrLLoqcRb4AGb+.VXUCSUpoH2qdUzdKEOT0iKMHWh3at6YwU63hQEY5BMpW.8IgpPZTg.z4N8efZijincDR5Iba0YwLV2ZguupQiVotnxDOp+JUqZq4+X.s4ymNj5m5l.sgv862sAh45afjt+lS3wsTFJ3s3L4Iyn700VAEcFEZvXFwJvTot8x2E0doptjAwftHYh5+WDooLHX2ks3QeAvO7+G7iRfarAvKsYucX1G8cSwnimtAcZq5DIQ0jNJbBg3YTeISk8LpSuBl9IrkcFy5zfKkhY53czwU32OgH90wuxOM73EIu+9GS4DnbPMQxGnD+ngfPeQt+v04dL4qg6OZct+SS9Z39Rqy8GO6y69c+7Y7Du+WMSG5KuZuyBZKlB9l3C1ZrE5gStAyOJbm6Qj2cnR0jzQJfKJtyzapIz3AL4hzSZ+rLo4SktuzrKS5LY07cqUvW37wyMeilaOqYiQinNxDxtiYye+4eHcTOwbIiOFlaymAEMlclOsO7YLNTfIbNz4BjAEDJn50ETq0GhobW8h+EdhTVTs1HRYwkJQSIN9hKbBuvR8kAuPKA3DW+ARYLaqViiui1zrP9BnoPM5ENNpPwOBbe0XNbCvbzFfozFf4Ma.l2tAX9oM.yO+nXTWOTYtTLM7XBHnaCcCCCiF56OzUjn+yfTygo 
                                          

                                          HISE Development for hire.
                                          www.channelrobot.com

                                          LindonL 1 Reply Last reply Reply Quote 1
                                          • LindonL
                                            Lindon @Lindon
                                            last edited by

                                            plus this small change to your random number generator

                                            local randomValue = Math.randInt(0, 4);
                                            

                                            HISE Development for hire.
                                            www.channelrobot.com

                                            DanHD 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            36

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.2k

                                            Posts