ID:1821099
 
(See the best response by Kaiochao.)
var
true=TRUE;
false=FALSE;
mob
proc
LoadInstallationResources() {
if(fexists('Sound Stream/BGM/01 - Install Theme.ogg')&&fexists('Sound Stream/BGM/01 - Install Theme Repeat.ogg')&&fexists('Sound Stream/SFX MENU/System Message.wav')&&fexists('Sound Stream/SFX MENU/System OK.wav')) {
src << browse_rsc('Sound Stream/BGM/01 - Install Theme.ogg');
src << browse_rsc('Sound Stream/BGM/01 - Install Theme Repeat.ogg');
src << browse_rsc('Sound Stream/SFX MENU/System Message.wav');
src << browse_rsc('Sound Stream/SFX MENU/System OK.wav');
alert("Files loaded!");
return true;
}
else {
return false;
}
}

http://gyazo.com/12eeda32f1bceb994148d41f53a1ea6e

For some reason this proc wants to return false. Is there any reason why fexists is returning false when the files exist in the directories specified?
Best response
Putting them in single quotes includes them into the game's resource cache, so they'll always exist. The fexists function is used to check for files in the game's directory that aren't resource files, such as save files. There's no way to check if a client has a file, I think.
In response to Kaiochao
Kaiochao wrote:
Putting them in single quotes includes them into the game's resource cache, so they'll always exist. The fexists function is used to check for files in the game's directory that aren't resource files, such as save files. There's no way to check if a client has a file, I think.

That's a good point, but fexists still checks if the files exist in a directory whether or not it's in the .rsc right?
The main reason I'm doing this is in case the resource files get corrupted since this game is aiming to be single-player.

EDIT: Would there actually be another way to check if the .rsc is corrupted such as catching an IOException like Java does?
In response to GameAnalysis
GameAnalysis wrote:
Kaiochao wrote:
Putting them in single quotes includes them into the game's resource cache, so they'll always exist. The fexists function is used to check for files in the game's directory that aren't resource files, such as save files. There's no way to check if a client has a file, I think.

That's a good point, but fexists still checks if the files exist in a directory whether or not it's in the .rsc right?
The main reason I'm doing this is in case the resource files get corrupted since this game is aiming to be single-player.

EDIT: Would there actually be another way to check if the .rsc is corrupted such as catching an IOException like Java does?

You can create this effect if you create a Server and Client for your game.
In response to GameAnalysis
GameAnalysis wrote:
That's a good point, but fexists still checks if the files exist in a directory whether or not it's in the .rsc right?

It checks if they exist in the game directory, but it never checks the .rsc. fexists() is concerned only with the files in the server dir.

The main reason I'm doing this is in case the resource files get corrupted since this game is aiming to be single-player.

I don't see how the resource file would get corrupted at all. It won't be altered except if the game is updated or you recompile. Dynamic resources are stored in a different file.
In response to Lummox JR
Lummox JR wrote:
GameAnalysis wrote:
That's a good point, but fexists still checks if the files exist in a directory whether or not it's in the .rsc right?

It checks if they exist in the game directory, but it never checks the .rsc. fexists() is concerned only with the files in the server dir.
So then why would it return false is they are clearly in the directory as shown in the image?
The main reason I'm doing this is in case the resource files get corrupted since this game is aiming to be single-player.

I don't see how the resource file would get corrupted at all. It won't be altered except if the game is updated or you recompile. Dynamic resources are stored in a different file.
It could get corrupted through file transfer being interrupted, improper decompression when extracting files, or if the file is being accessed through a flash drive and the drive is removed.
In response to GameAnalysis
GameAnalysis wrote:
Lummox JR wrote:
It checks if they exist in the game directory, but it never checks the .rsc. fexists() is concerned only with the files in the server dir.
So then why would it return false is they are clearly in the directory as shown in the image?

Well for one thing they're in your development dir, but they won't be on the end user's system after the game is installed unless you package them with the host files. They will however be in the .rsc, since you single-quoted them.

But the reason fexists() is returning null is that you're calling it wrong. A single-quoted file is a cache reference--referring to a file in the .rsc. The fexists() proc only checks your server dir for files, so it only accepts a string (double-quoted) or a file(). It's returning null because you sent it a cache file as an argument, not a string.

I don't see how the resource file would get corrupted at all. It won't be altered except if the game is updated or you recompile. Dynamic resources are stored in a different file.
It could get corrupted through file transfer being interrupted, improper decompression when extracting files, or if the file is being accessed through a flash drive and the drive is removed.

The first two cases are installation error, a one-time problem that's easily corrected (and not very likely in any case). The last is user error. If you're hosting off a flash drive and unplug it, problems are to be expected. (Nor would that represent corruption in any event; the file would simply no longer be there.)
In response to Lummox JR
I don't see how the resource file would get corrupted at all. It won't be altered except if the game is updated or you recompile. Dynamic resources are stored in a different file.
It could get corrupted through file transfer being interrupted, improper decompression when extracting files, or if the file is being accessed through a flash drive and the drive is removed.

The first two cases are installation error, a one-time problem that's easily corrected (and not very likely in any case). The last is user error. If you're hosting off a flash drive and unplug it, problems are to be expected. (Nor would that represent corruption in any event; the file would simply no longer be there.)

The concern isn't about hosting it, the concern is about transferring it to other people. I'm going to be distributing copies of a single-player version of the game through file hosting for free and flash drive for a price.
Then a multiplayer version of the game is going to be hosted through BYOND that people can connect to through either knowing the IP:port or the single player client provided through download.

Judging by what you are saying though, it seems like I would have to check if a file exists in the .rsc and if it doesn't that I will have to grab a new .rsc from a server, right?
You could try md5()'ing the rsc file itself to ensure it's valid, if you're that concerned about corruption.
But again, why are you concerned about corruption? File transfer is pretty much a no-brainer these days. The odds of the .rsc getting corrupted in transfer are about nil.
In response to Lummox JR
Lummox JR wrote:
But again, why are you concerned about corruption? File transfer is pretty much a no-brainer these days. The odds of the .rsc getting corrupted in transfer are about nil.

Yeah that's a good point. I should have thought of that I guess "^_^