HISE Logo Forum
    • Categories
    • Register
    • Login

    Randomizer on 3 Grouped buttons, How?

    Scheduled Pinned Locked Moved Scripting
    97 Posts 4 Posters 4.6k 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 @Natan
      last edited by

      @d-healey No Idea,can't do it by myself :)

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

        @Natan Yes you can, one step at a time. You're not by yourself, I'm here :D

        Can you create an array?
        Can you create a button?
        Can you put a reference to the button into the array?

        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
          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.3ocuW8tahbCD2aR1SGaKU8j5CfU9vIPWJAR3tVI5oF96ITCDDPhZ0oSQlcMfU10FsqIMnnH0OUo9BzGo97z2f1wdWX2P1jlPSq+Bq8L+F+yyL1yPOegMMHP3iLxLbwLJx3yMGrfKmVeJgwQsafLdoY+pcabRGTsEyHAATGjgw1ePI0HyNH83O+9ZDWB2lFuDBclfYSOl4wjwq16nef451h3PGx7Rnc4iZaK30Eth4.S11rHZFw9BxDZWhRssLQFunoCSJ7GHIRZ.xXmZBmEClJ9Ydn9mwBXibopIkPC.CEtbKgqihwpUQ0mxbc5s7DGf.qzK97uc34+qL6vbXqVO1O7kZA3XDI8GFa8PzqTR5ULU5ULM5Yjfd6DRuWYNv1mMSFKQwsOyrMWR8GSfPPRZEpKZqe0zrt.zfKK3Qtf1xGlrBQt2Ur3d32VrX9JYsxZsOLvc9IbsSGN7jtCv43PLvA6S3NBO7XgOlKv9TRffmOqED1Bj3KI93QRd+PcdO9iK2sITYcg2LAGlja2vDoR6leurV3zGODvC1TfGto.Kua9OE6T5VcXUvgDJJx+nDx3tLNEOdN2VxDbrP6HZOTYYegaN6klcOvQ4Nml25ZKMabE1D2HO6YJIfqqCQNsfZIH9jChKGluhUDMCDtzBy7YffDXxWAjFZO1XbtKCsy6wkxqW65km6UwmOl.7mJDPk5uxUJZitIT8rIXHy4JfYqLPAF2gd0IiiOXpLGMJU5QNFnbwJXF96RfwkxmHmBq9l2jOT4qiCIwbikfQL0wPs2u90QNtns4lvertohk08D9zAfcyqLVTXnNw0cD7pRt0BOIx5GVsVslMvs6NrY+VUq2DOnd+18FpjGmm28zNmCJN.Njk0PW+LuTgkm0ny45mw0ok8TBeBcHYjhP2DxIXFdzboDRprizaUZ1cy6VYg6lwshE6u+GnRrN.hEiw1tL6Kfa2gaxlEyWkr.7ULYhKMxZAgq9+VJQjWCBHwWD6JjzS34T23xXciEdcQiGmprnXiK0OUwphW9ODvb74din9ItuqUDdE+1kILu+xDIqhYGlimPQAuMmIOYFkee01PQWLfxHlQrBTUpKh7EQEQpoiSHFTqHSTU9RHMkUEOPOAXGrB1VOEXGtY6V4mFLnCF8E9knh6QAcZ6FDIQUpMxcAtvYTeISEcLZPuD5gIrvaFyFzfKjhYZ+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
                                            • First post
                                              Last post

                                            14

                                            Online

                                            1.7k

                                            Users

                                            11.9k

                                            Topics

                                            103.2k

                                            Posts