Check if image exists (also after deployment) [Solved]

Status
Not open for further replies.

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
JavaScript:
pictureExists = function(filename) { // filename must include file extension.
    const fs = require ("fs");
    return fs.existsSync("./img/pictures" + filename);
};

See also here.

The code above works in the editor but after deploying my project, it always returns false. How do I make this work for both cases (on all platforms)?
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
3,194
Reaction score
1,190
First Language
Dutch
Primarily Uses
RMMV
maybe an "if statement"

if {!filename}
throw new error
else return true ?

that might be the most logic idea though, but idk the most efficient way.
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
Filename checking is not required because the ImageManager does this internally.
I need to check if the image exists on disk.
 

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
168
First Language
English
Primarily Uses
RMMV
When deployed, the pictures folder is no longer one branch from the launcher but at /www/img/pictures/. You might wanna look at what I posted here, it works both in the editor and when deployed:
You can use the plugin or if you want copy the bit you need :')
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,608
Reaction score
14,331
First Language
English
Primarily Uses
RMVXA

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Chilling out while toodling around someone's painstaking Minecraft recreation of Disneyland. It is mind-boggling and probably as close as I'll ever be to going.
>Testing with fonts change.
>Tries installing a plugin. Doesn't work.
>Tries changing the plugin commands. Doesn't work.
>Tries installing another plugin. Doesn't work.
>Changes a few more plugin commands. Doesn't work.
>Goes directly to the gamefont file and changes the src. Works.

YYEEEAAAAHHHAAAA

Perseverance is key, bois and girls.
What Reviews say on RPG Maker MZ?
Looking back at some sketches, and game design documents on my PC dated summer of 2015. I started development with the release of MZ, but in 2015, I felt a strong desire to make a game out of the blue. I remember feeling sad for no apparent reason, and all these ideas rushed into my head. Now that I think about it, since that day, everything has become easier to do on my PC . . . it’s very creepy.
Everything's going to be alright! We're all in this together. <3

Forum statistics

Threads
107,806
Messages
1,032,349
Members
139,952
Latest member
4kWave
Top