ID:716945
 
Not a bug
BYOND Version:494
Operating System:Windows Vista Home Basic
Web Browser:Chrome 18.0.1025.162
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
When trying to compare the current sound() being played with a file("textstring_path") in an if statement, it appears to fail even if said text string is the correct path. But if one were to compare the current sound with file('path') for testing purposes, the if statement will not fail.


Code Snippet (if applicable) to Reproduce Problem:
Here I have created a quick verb which demonstrates the problem. This first snippet shows that file() appears to work properly. (It is obvious that file() is not needed in this situation, but it is for debugging purposes.)
mob
var/sound/sound
Login()
..()
sound = sound(file = 'songs/sound.ogg')
src << sound

verb/issound()
var/song = file('songs/sound.ogg')
if(sound.file == song) world << "The song is playing!"


If you replace the above issound() with this one, you will see that I am trying to compare the current sound to file("textstring_path"). Unfortunately, it appears that if the path within the file() procedure is a text string, it will not return a file object.
    verb/issound()
var/song = file("songs/sound.ogg")
if(sound.file == song) world << "The song is playing!"


Expected Results:
When one does if(song.file == file("textstring_path")), and said "textstring_path" is equal to song.file, the statement should be true.

Actual Results:
The statement is false.
When you do it with single-quotes you're referencing a file inside of the rsc, when you do it with double-quotes you're referencing a local file. The results of the two won't be the same.

You'll also be forced to include any files referenced in double-quotes with the game package, as they won't be referenced from within the rsc file.

From what I can tell, things are working perfectly correct in this case.
In response to Nadrew
Nadrew wrote:
When you do it with single-quotes you're referencing a file inside of the rsc, when you do it with double-quotes you're referencing a local file. The results of the two won't be the same.

Ah, makes sense. Thank you and I appreciate your explanation.
Just for reference, you can use fcopy_rsc() to get the file as a resource cache entry:
if(sound.file == fcopy_rsc(song)) world << "The song is playing!"
Lummox JR resolved issue (Not a bug)