Allowing Glob pattern for @requiredAssets parameters

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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 :> 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
as a workaround, you can check out my last plugin.  It updates itself with the list of sprites required.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Upper Autotiles :)
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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

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' });
        }
      }
    }
  };
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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 :)  
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top