Allowing Glob pattern for @requiredAssets parameters

SO I worked a lots with MV recently I like the exclude files options and the "requireAssets" options ALTHOUGH I bunked on a little errors


What's happen when you let the player generate their own sprite?


Because I work on something who actually let's the player choose how many sprite are generated


e.g : the players input a number and it's will get in count the number of sprite.


var numberOfSprite = 10;
System.prototype.GenerateSprite = function(){
for(var i; i < numberOfSprite; i++){
ImageManager.loadSpriteFolder("Dress" + i.toString());
};


Now okay fine I can make the sprite fines...the problems....what if the person use the options to remove unused files ...it's will remove all the sprite!


because I can't require the asset for being avoid to being removed on deployment ... because I don't know HOW many number of sprite I need.


so I though  suggesting this idea would be good


the pattern for that would be like : 


* @requireAssets img/example/*




I hope this can be implemented :> 
as a workaround, you can check out my last plugin.  It updates itself with the list of sprites required.
as a workaround, you can check out my last plugin.  It updates itself with the list of sprites required.

Hum wich one? I tried to find it but I don't remember what's your plugin name again haha
Upper Autotiles 🙂
Upper Autotiles 🙂

Ohh you mean this?? so EVERYTHING'S who are in the create of Scene_Boot is required??


EDIT : oh no gosh you created your own "glob" pattern for the required system XD

Spoiler
Code:
  // Add image files to required assets list, to ensure they are included
  // in a deployed project
  var _upperAutotiles_Scene_Boot_start = Scene_Boot.prototype.start;
  Scene_Boot.prototype.start = function() {
    _upperAutotiles_Scene_Boot_start.call(this);
 
    if (Utils.isOptionValid('test') && !DataManager.isBattleTest() &&
      !DataManager.isEventTest()) {
 
      // Read in this script
      var fs = require('fs');
      var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/');
      if (path.match(/^\/([A-Z]\:)/)) {
        path = path.slice(1);
      }
      path = decodeURIComponent(path);
      path = path + 'js/plugins/UpperAutotiles.js';
      if (fs.existsSync(path)) {
        var source = fs.readFileSync(path, { encoding: 'utf8' });
        source = source.split('\r\n');
        var resListStart = source.indexOf('RESOURCE LIST - DO NOT MODIFY BELOW THIS LINE');
        var resListEnd = source.indexOf('RESOURCE LIST - DO NOT MODIFY ABOVE THIS LINE');
        if (resListStart === -1 || resListEnd === -1) {
          console.log('ERROR - Unable to create resource list for UpperAutotiles.js');
          console.log('Please redownload the script and paste over your current version');
        } else {
          // remove previous list of resources
          source.splice(resListStart + 1, resListEnd - resListStart - 1);
          // build list of new resources
          var resources = [];
          $dataTilesets.forEach(function(tileset) {
            if (tileset) {
              tileset.autotileInfos.forEach(function(autotileInfo) {
                if (resources.indexOf(autotileInfo.filename) === -1) {
                  resources.push(autotileInfo.filename);
                }
              });
            }
          });
          // add resource list to script
          var inspos = resListStart + 1;
          resources.forEach(function(filename) {
            var tag = '* @requiredAssets img/' + autotileFolder + '/' + filename;
            source.splice(inspos, 0, tag);
          });
          // and save the file
          source = source.join('\r\n');
          fs.writeFileSync(path, source, { encoding: 'utf8' });
        }
      }
    }
  };
yep, that's the one.  The meta system only allows one of each type of note in the notebox.  But because a tileset can have many <autotile: > notes, the meta system would only know about the last one.  So I had to come up with a way to add the resource to the script for every <autotile: > note for every tileset.


You might not want to do it with * - don't you define some sort of pattern the file name must match?  If you use * it kind of defeats the purpose of excluding unused resources, because * really would include resources even if they're not used.
yep, that's the one.  The meta system only allows one of each type of note in the notebox.  But because a tileset can have many <autotile: > notes, the meta system would only know about the last one.  So I had to come up with a way to add the resource to the script for every <autotile: > note for every tileset.


You might not want to do it with * - don't you define some sort of pattern the file name must match?  If you use * it kind of defeats the purpose of excluding unused resources, because * really would include resources even if they're not used.

Actually  I was thinking a pattenr more like : 


/*:
* @requiredAssets img/example/dress_*
*/
// Will only "require" the assets from the name pattern them a extentions who are a numbers


this a idea I think should be implemented for massive asset who have variables index asset name.
Yeah, that would be better.  Anyway, if you need it in a hurry, you should be able to do something similar to what I've done.
Yeah, that would be better.  Anyway, if you need it in a hurry, you should be able to do something similar to what I've done.

Not that much in "hurry"  but yeah I will use your method until they have a official workaround for glob pattern in requiresAssets


Thanks shaz 🙂  

Original thread: https://forums.rpgmakerweb.com/threads/allowing-glob-pattern-for-requiredassets-parameters.66745/