HISE Logo Forum
    • Categories
    • Register
    • Login

    Randomizer on 3 Grouped buttons, How?

    Scheduled Pinned Locked Moved Scripting
    97 Posts 4 Posters 5.7k 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.
    • d.healeyD
      d.healey @Natan
      last edited by

      @Natan Well have a go at it and see how you get on. When you get stuck show me what you've got and we'll go from there.

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - Public HISE tutorials
      My Patreon - HISE tutorials

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

        @d-healey said in Randomizer on 3 Grouped buttons, How?:

        at it and see how you get on. When you get stuck show me what you've got and we'll go from there.

        Let me focus on it, thanks Sir :)

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

          I only can do it in this dirty way :(

          HiseSnippet 1117.3ocyW0saaaCElxILn1YtnEqO.B4Jaft.I61tgUDLO6jTXrkTi5zfcWAiDsMgkHEjnRpaP.1ix.1KxdK1qQeC1NTR1h1Q9mXr.L4Kr442O+cn34vdgBGZTjHDYT9hIATjw2f6OgKG0YDgwQcOFY7T7YjHIMzLUT6IAjnHpKxvXm2oDXTdWTxyW+o1DOB2glKBgtTvbn+JymIyk1q0uv77Nk3Ruf4qY8qZ00Qv6H7Dw.d1AagBHNiIComSTlUBiL16DWlTD1WRjzHjwtsEtS5ORbCO09KYQrq7npE1n9PfREepvyUgXkTTmQLO2dS+eGgfnzKmE1IkEdA9LlKal7b13YIJLy8PmOLJsJ3YqCOqMGdFZva2T38bbemPVfLWiBa6i6xgB0.BTBzgUpsnR+IF2Q.VvkG5SFSOMDVLyiZuwx5klu1xp9aqVQ8AJEQRyqIglefvcaew4lGYN08gTYGgeffCKpcPl9CTdNuWB+04WhEGb+b1VxsWpiJkKjMPTiUYei6aeyUYeyYXpZEF2iwolCh4NRlfaJ3Y+iUdGJ7p4L00WBw1KlVuZkaqVorI7vFXVKQl4QGYZAJTBMuM6a0yzetVN5vHp7RUnpcFQN5vPPCT8pAUsl0UfcSCiyHBeH0sV82lm7zutKaYQX29++X+tjJ1Z1ipPRVcqCwy6J3DlZKVPyK8Ku7mfnUuAPAqnaXRmQY7XBEd6LdygDQMs9wzEp8z4rj8TRQs0MWrkl3lEH9pPJYb1u0xgcg4vp3bXuQ4XZ70xRiGRVVx+D6ExBTTWecUaOVwUV8ZUZsUqXdtPReOuV8J2Vobk6pXtnpACJTWV37ngEpV0YKbUNViG6eEMb5FloFBGwOeOD7x6gn2hyIkczLTv6xYx2GP4KqyBJiRUs.yPEXpLoCySy5vzNVJEbDCZjTFm8VBJAx5M9Qaf66gUaLl46dFSGQXS8sQtunGpuMKv2O18XhjnZvlwC.2DPCkLEsabL8ZXxkz1skwGSiFKEAP4X1dOfz1.p5yyno+RzZxrE+9EsPZQBuNVKOLnOpEFyAsBItLw6BEwAKTP1zf2PK3OK3+3f2TK3e8KOzfu+7AuuGykFlD78wyduVKC+wXsLXE2xmnwanVvTrA8YeAhHFaenEJhbMsKuWHEN3PMmDkSf2rRFYRR+LH5ayxhoZJldLmwP1ug4JGAQv3ugPNhxFNRwBF1IC1duA0fwEEtwdD47yPpFbNSAbnvbCqoFHiGwjSzIkGkAK2T39bbOUOrhwaoBvK7J0iMdyFSuJ9jACnNxbvtK9ze6welbzGDwRFeHLLSHC1igOO1uObqEGJfDNm5oN31nj5.pz0Vp0JloOk6lr3efmLk1p0FYJsmpD4SbBEexI8DN0EAdRhD.S7j6CUFtXFr1b1YpXrErq1GtexmbbTTw2AXuXeZrE9zbK74UagOudK74MagOe+V3yOrReTWM7mikB+zWS.A8NIoGigwI4msf9WLAGGPB
          
          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey
            last edited by

            Make a new file. Generate a random value between 0 and 2 and output it to the console.

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - HISE tutorials

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

              @d-healey Is This Good Sir?

              HiseSnippet 807.3ocsUstSaCCE1tfQzrUzPZO.Q7qVotpTtsIglFqWXpZCnhxPSBgPFGWpEI1YINrUg38bOF6MX63bgFXUEnRq+pmKeG+ki+NG2OTw3QQpPDt7wiC3H7KICFK0iZOhJjndcP3UH6Siz7P6TWsFGPih3tHLdgOYbfKuHJ42u+PKpGUx3SbgPmnDL9WD9B8Du828yBOu8nt7iE9Exdyc6wTx1JOULvmEHNn.J6J5k7CnlzJQP3k55JzpvAZplGgvK1R4NdvH0Ojo4ehHRbgG2XzDM.JTp68TdtFFa7hZOR341O+6NBAUo+jtvBocgWS1W3Jty+jtwqRBXOAQw9AtzrnWyGmdNSid3BzawT5sJY.KTDnmDwvsWP5IgKpgT3JnHsRyEU5WXRaEjgT2vmdEeuPv3NDU21wot8VNN01ohUEK3hHRaeMMz1e7ITuXdj86sO0ody5qWeiy1oXBGQkt8NFBmW7K451J+.kDLptVZ30RKqP5Ijb6gwRlVnj1JYZXCzPkWUVNt5PogSsVEqapXYW3GjYjxi2HHT.UOmbmtOUOpQnoVfW3CYyZmUaGa6JV2lbtylZMhLtSXPapm2Efpq5CXlg9EX8AJM+PY0ZV2XU15VK6GFZ3voFKqXd7voF1LNDNKfUkw9WvCyaN4IB5h6K7V5oI7XockBIpj8jB8gA7L6YO4fxZqFQZFCgT0IRzUxjnsh0ZkDIfhrLIskhRXewsDnu1qCUSyqCTR3XB3gZg4qA2geMrEIU5WlzgGckVEjja1UIz.d7S8mHLA+c3vFa9y5Iah9mIKX9V4F6Q02en2roKK.bgbuoKyDjLRnGWbS3yXSfySdQ0SktqR5KzrQSmuklBeg99+a9lsWsBo6vgbldBYWjr22l2knOCpbjJVKjWBqIBEFgvAw9CfmYXbfIRI2KxnIJYjzo1NFaSmY.W5lX7G3WVvlFabVvl4AQ9TVn5bV5ffYy8xId.NISd.qL7RJXa2Le.fPbZ3f7gGTNmwLsh2.be5XVeNvrwbfYy4.yVyAlsmCLucNv7tYhw7V9Gi0J+zwDvQ+tIKhv3tRJnxRTjn+xdlqWc
              
              1 Reply Last reply Reply Quote 1
              • d.healeyD
                d.healey
                last edited by d.healey

                It's a good start but there are a few problems.

                1: I said forget about buttons. Just Console.print() in on init.
                2: Your function is generating numbers between 0 and 3, you need 0 and 2

                This is all that was needed

                const randomValue = Math.randInt(0, 3);
                Console.print(randomValue);
                

                Since you're addicted to buttons let's move on to them :p

                Add your 4 buttons, put the 3 you want to be random into an array. In the callback for the other button generate a random number between 0 and 2, like you did in your last snippet, and output it to the console.

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - HISE tutorials

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

                  @d-healey Haha :) Sir!!!

                  NatanN 1 Reply Last reply Reply Quote 1
                  • 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?

                      Free HISE Bootcamp Full Course for beginners.
                      YouTube Channel - Public HISE tutorials
                      My Patreon - 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.

                          Free HISE Bootcamp Full Course for beginners.
                          YouTube Channel - Public HISE tutorials
                          My Patreon - 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.

                              Free HISE Bootcamp Full Course for beginners.
                              YouTube Channel - Public HISE tutorials
                              My Patreon - 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?

                                  Free HISE Bootcamp Full Course for beginners.
                                  YouTube Channel - Public HISE tutorials
                                  My Patreon - 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!

                                        Free HISE Bootcamp Full Course for beginners.
                                        YouTube Channel - Public HISE tutorials
                                        My Patreon - 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

                                            Free HISE Bootcamp Full Course for beginners.
                                            YouTube Channel - Public HISE tutorials
                                            My Patreon - HISE tutorials

                                            NatanN DanHD 2 Replies Last reply Reply Quote 3
                                            • First post
                                              Last post

                                            14

                                            Online

                                            2.0k

                                            Users

                                            12.7k

                                            Topics

                                            110.4k

                                            Posts