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

Status
Not open for further replies.

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
423
Reaction score
170
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
1,696
Reaction score
556
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
423
Reaction score
170
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
165
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
12,955
Reaction score
13,314
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.

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

Latest Threads

Latest Profile Posts

Playtesting for Battle Castle is done, demo time for me was roughly 6 hours and 20 minutes. I'm going to pass it on to a few friends first, and after getting some feedback will be posting an official topic.
There's another Humble Bundle available now for RPG developer assets, this time focused somewhat more towards pixel art style games.
Ive got a long lost half uncle. Thats real cool.
I forget what is bumping rule in this forum. Is anyone know? Thank you.
BCj
Ew, why does my blogpost on the rpgmaker.net site look like a garbled mess? Are html codes disabled or something?

Forum statistics

Threads
97,909
Messages
947,782
Members
129,148
Latest member
lemminace
Top