[MV] ZE - File List

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
ZE - File List
v1.0.0​
 ​
 ​
Overview
This plugin maintains a list of all files available in a project's directory. This allows the game to know what files are available to it without looking directly at the filesystem every time it needs to check. This also allows games in web mode to know what files are available to it, as the results are stored in a file within the game's data folder (this can be changed). The file list is updated every time the game is started in local mode.
 
 
Installation
This plugin requires zAPI - File Tools!
Once you have the API installed, grab the File List here!

Usage

This plugin maintains a list of files present in a project so that other plugins can easily identify all the files available to them. This plugin provides functions to search the list with regular expressions.

 

The file list can be directly accessed via FileList._list

 

There are 3 functions available to filter the results found in the file list:

 

To just look at file names, use FileList.scan(regex).

 

To just look at file paths, use FileList.scanPath(regex).

 

To look at both the file path and file name, use FileList.scanWithPath(regex).

 

All of the scanning functions will return an array with results that match your regex. If no items matched, the array will be empty.

License

This plugin is released under the Creative Commons By Attribution 4.0 license. You may do anything with this plugin, including use it in a commercial project or plugin. The only restriction imposed upon you is that you must credit me, and you may not claim that you wrote the original plugin.
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,100
Reaction score
367
First Language
indonesian
thanks for another great plugins... i will try comboing this with sanshiro virtual RTP.

his plugin can redirect load path to :

file:///C:/Program Files (x86)/KADOKAWA/RPGMV/NewData/

so we can delete all our images and upload it to net with small size. then when people download that project. they just need to set the load path to where they install their MV (if they don't change it... then no configuration needed)...

but because of that it also won't detect for new files we added inside the project folder instead.

using this i could add check the project folder before redirecting it to virtual RTP.

i think with this and sanshiro virtual RTP we can do like ACE where we can create <5mb demo for our scripts...

edit: i already installed the zAPI - File Tools above this zlist

but still get this error in console

Uncaught Error: ZE - File List requires zAPI - File Tools

EDIT:

found a way to bypass that error. by commenting the "require" code. :D .

another question... does this check is asynchronously... i try checking file exist or not.

if exist call original path. if not exist call virtual path. but somehow... there's a problem.

first file > exist in original path and virtual path

second file > exist in original path and virtual path

third file > not exist in original path and exist in virtual path

fourth file > exist in original path and not exist in virtual path (our custom resource).

so first check... pass

second check... pass

third check... pass... it will load the virtual path

fourth check... error not file found... it load the virtual path

here's the code btw:

Code:
    var estOldImageManagerLoadCharacter = ImageManager.loadCharacter;    ImageManager.loadCharacter = function(filename, hue) {        regex = new RegExp("img/characters/"+filename+".png",'img');        if (FileList.scanWithPath(regex)[0])        {            console.log("enter original")        return estOldImageManagerLoadCharacter.call(this,filename,hue);        }else{            console.log("enter virtual")        return this.loadBitmap(VirtualRTP.imgPath + 'img/characters/', filename, hue, false);        }    };
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
edit: i already installed the zAPI - File Tools above this zlist

but still get this error in console

Uncaught Error: ZE - File List requires zAPI - File Tools
You're still getting that? Odd, I haven't gotten that error at all, but if you're sure the API is loaded correctly, then commenting out the error should fix that.

another question... does this check is asynchronously... i try checking file exist or not.

if exist call original path. if not exist call virtual path. but somehow... there's a problem.
Yes, the list is loaded asynchronously while the game is starting up so that we don't lag the game. Since some computers may be slow to load data from the disk, the plugin does everything async to avoid slowing the game down. you can check if the list is finished updating be checking FileList._updating.

first file > exist in original path and virtual path

second file > exist in original path and virtual path

third file > not exist in original path and exist in virtual path

fourth file > exist in original path and not exist in virtual path (our custom resource).

so first check... pass

second check... pass

third check... pass... it will load the virtual path

fourth check... error not file found... it load the virtual path

here's the code btw:

    var estOldImageManagerLoadCharacter = ImageManager.loadCharacter;    ImageManager.loadCharacter = function(filename, hue) {        regex = new RegExp("img/characters/"+filename+".png",'img');        if (FileList.scanWithPath(regex)[0])        {            console.log("enter original")        return estOldImageManagerLoadCharacter.call(this,filename,hue);        }else{            console.log("enter virtual")        return this.loadBitmap(VirtualRTP.imgPath + 'img/characters/', filename, hue, false);        }    };
What is the filename you are checking? You're escaping the filename at all, so if it contains any special Regular Expression characters, it will mess with your expression.
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,100
Reaction score
367
First Language
indonesian
What is the filename you are checking? You're escaping the filename at all, so if it contains any special Regular Expression characters, it will mess with your expression.
now that you mention it... the filename is $rumah.png

does it error because of $ sign?

btw the console log also show that there's some "enter virtual" even though the map have event which picture all available locally.
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
now that you mention it... the filename is $rumah.png

does it error because of $ sign?
Yes, that will cause an issue with it. $ is a special caracter for regular expressions that means the end of a string, so your expression in this case can literally never be true, because it's reading it as "img/characters/<End of string>rumah.png", so it will never match. You'll need to escape the filename by using a function similar to this one:

String.prototype.escape = function() { return this.replace(/[\-\[\]\{\}\(\)*+?.,\\\^$|#\s]/g, "\\$&");}That should turn any special character into the escaped version, making it look for that character specifically.

btw the console log also show that there's some "enter virtual" even though the map have event which picture all available locally.
Again, are you sure the filenames don't have any reserved characters? You can try to test your regular expressions here.
 

NecroTheif

NecroLore
Veteran
Joined
Dec 14, 2012
Messages
43
Reaction score
6
First Language
English
Primarily Uses
When I run your ZE - File List Plugin I get this error:

Code:
Uncaught Error: ZE - File List requires zAPI - File Tools

 


I have installed zAPI - File Tools (Add it to plugins folder and added it with the plugin manager) And when I comment out the imported line I get this error:
Code:
GET http://localhost/data/Filemap.json 404 (Not Found)

And when I run it local (without the imported line) it crashes saying:
Code:
Uncaught ReferenceError: MVC is not defined
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
It seems I forgot to mention that zAPI - File Tools requires the MVCommons plugin to function correctly. Please be sure to install that plugin as well and then let me know if there's still a problem. I'm working on a school project right now, but I can quickly edit the zAPI post to mention tat requirement, as that was my mistake for forgetting it.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Demo for Maze of the Lost MZ released. I would appreciate any and all feedback and constructive criticism. If you like Dungeon Crawlers and JRPG's with a hint of Metroidvania and Shadowgate/Uninvited you might like it. https://forums.rpgmakerweb.com/index.php?threads/maze-of-the-lost-mz-demo-port-from-mv.127971/
Well, here it is, colored. :kaoslp:

Forum statistics

Threads
103,388
Messages
998,954
Members
134,906
Latest member
Sikey
Top