HISE Logo Forum
    • Categories
    • Register
    • Login

    getExpansionForInstallPackage()

    Scheduled Pinned Locked Moved Scripting
    15 Posts 2 Posters 349 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.
    • CasmatC
      Casmat
      last edited by Casmat

      Hey!

      I am working on setting up an importer for my expansions and I am trying to get a way to connect to a json file in the expansion that the importer has installed in my installation callback. Heres my code right now:

      expHandler.setAllowedExpansionTypes([expHandler.FileBased, expHandler.Encrypted, expHandler.Intermediate]);
      
      inline function installCallback(obj)
      {
      	if(obj.Status == 2 && isDefined(obj.Expansion))
      	{
      		Console.print("running"); //check
      		local jsonfile = FileSystem.getFolder(FileSystem.Expansions).getChildFile(expNameInstall).getChildFile("AdditionalSourceCode").getChildFile("expInfo.json");
      		local jsonobject = Engine.loadFromJSON(jsonfile.toString(0));
      		Console.print(jsonobject["version"]); //check json works
      	};
      };
      expHandler.setInstallCallback(installCallback);
      
      inline function onbtnImportInstrumentControl(component, value)
      {
      	FileSystem.browse(FileSystem.Downloads, false, "*.hr1", function(result)
      	{
      		if(isDefined(result) && result.isFile())
      		{
      			var expNameInstall = expHandler.getExpansionForInstallPackage(result).getProperties().Name;
      			expHandler.installExpansionFromPackage(result, FileSystem.getFolder(FileSystem.Samples));
      		};
      	});
      };
      
      Content.getComponent("btnImportInstrument").setControlCallback(onbtnImportInstrumentControl);
      

      bit messy, but Im wondering if this will work in the release ver of the plugin. I saw the desc of the getExpansionForInstallPackage() function say that it will check for installed expansions and only return a value if the expansion exists. Everything works now, but I wonder if its because the expansion is already "installed" since its the development ver and that it wouldnt work in the release ver. And do you guys have any ideas to cut down on some code? I feel like I'm trying to get the name of the expansion from the package in a very ineffective way..

      Thanks!

      i make music

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

        @Casmat

        After the expansion has installed I think you need to call the refreshExpansions function.

        Then you can load the json with the expansion.loadDataFile function. No need to use the file API. Expansions were around years before that.

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

        CasmatC 2 Replies Last reply Reply Quote 0
        • CasmatC
          Casmat @d.healey
          last edited by Casmat

          @d-healey thanks! Should i keep expNameInstall where it is right now, or should i move that into the installation callback since wouldnt the expansion not exist when the expNameInstall var is in the first line of the browse function?

          i make music

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

            @Casmat I don't see why you need that at all.

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

            d.healeyD CasmatC 2 Replies Last reply Reply Quote 0
            • d.healeyD
              d.healey @d.healey
              last edited by

              Assuming your install button is momentary you should check its value before showing the file browser, otherwise it will trigger twice.

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

              1 Reply Last reply Reply Quote 0
              • CasmatC
                Casmat @d.healey
                last edited by

                @d-healey ahhh, we’d be using obj.Expansion, makes sense now! And will take note on the button check, Thanks again!

                i make music

                1 Reply Last reply Reply Quote 0
                • CasmatC
                  Casmat @d.healey
                  last edited by

                  @d-healey tried using loadDataFile but kept on getting unkown function errors, how do I use it? Or what should I put in as the relative path?
                  Tried this:
                  Expansion.loadDataFile(obj.Expansion)

                  i make music

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

                    @Casmat Expansion should be an expansion object.

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

                    CasmatC 1 Reply Last reply Reply Quote 0
                    • CasmatC
                      Casmat @d.healey
                      last edited by

                      @d-healey Ahh, thanks! what should i put in as the relative path?

                      i make music

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

                        @Casmat Probably just needs the name of the json file.

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

                        CasmatC 1 Reply Last reply Reply Quote 0
                        • CasmatC
                          Casmat @d.healey
                          last edited by

                          @d-healey Tried it:

                          obj.Expansion.loadDatafile("expInfo.json")
                          

                          Still gives an error:

                          function not found
                          

                          i make music

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

                            @Casmat

                            What does Console.print(obj.Expansion.getProperties().Name); output?

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

                            CasmatC 1 Reply Last reply Reply Quote 0
                            • CasmatC
                              Casmat @d.healey
                              last edited by Casmat

                              @d-healey Morphology - Night Owl name of the expansion trying to import

                              i make music

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

                                @Casmat Oh I see the problem. You have a typo ;)

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

                                CasmatC 1 Reply Last reply Reply Quote 0
                                • CasmatC
                                  Casmat @d.healey
                                  last edited by

                                  @d-healey haha! Found it! silly me:face_with_tongue: sorry for the hassle!

                                  i make music

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

                                  57

                                  Online

                                  1.7k

                                  Users

                                  11.7k

                                  Topics

                                  102.2k

                                  Posts