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,705
Reaction score
562
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,961
Reaction score
13,317
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 Profile Posts

A mousefolk sprite I made, I think I did good.
Discovering math. functions for damage formulas was one of the greatest things for me.
It's very useful for balancing skills to work in a variety of possible circumstances.
For example if you have a skill that is supposed to work for both mages and warriors:
Code:
Math.max(a.atk * 2 - b.def, a.mat * 2 - b.mdf)
SpaceX: First-ever successful (manned) commercial spaceflight!! In these terrible and self-sabotaging times for the world, that's a ray of excitement and hope I needed badly.
GameDevJohn wrote on whtdragon's profile.
Hey I used you bunny and cat spritesheet for a game jam game. Thanks so much! You have really beautiful stuff here. I'll credit you at https://gamedevjohn.itch.io/bunny-boy

Forum statistics

Threads
98,018
Messages
948,574
Members
129,276
Latest member
abhikhurana
Top