Zwiebelchen
Hosted Project GR
- Joined
- Sep 17, 2009
- Messages
- 7,234
What would be an efficient way to find out if an external, readable file exists at WC3 runtime?
So basicly, what I want to do is the following:
If a user has Local File support enabled and some music placed inside a certain folder; the game detects that on map init and sets a player flag which makes the map load different sound files for the music played in the map.
Playing the sound files is local code anyway, so there shouldn't be any chance for desyncs. All I need is a "file exists" check from inside the map.
I mean, the following should work, right?
This way, a user would just have to enable local files and drop external music files into the specified folder in the WC3 directory. If a user doesn't have local files enabled or doesn't have the music files, it will just play the default track instead.
So basicly, what I want to do is the following:
If a user has Local File support enabled and some music placed inside a certain folder; the game detects that on map init and sets a player flag which makes the map load different sound files for the music played in the map.
Playing the sound files is local code anyway, so there shouldn't be any chance for desyncs. All I need is a "file exists" check from inside the map.
I mean, the following should work, right?
JASS:
local string default = "Music\\Doom.mp3"
local string custom = "MyFolder\\CustomMusic.mp3"
local string path = ""
local sound s
if GetSoundFileDuration(custom) > 0 then
set path = custom
else
set path = default
endif
set s = CreateSound(path ,false, false, false, 10, 10, "")
call StartSound(s)
This way, a user would just have to enable local files and drop external music files into the specified folder in the WC3 directory. If a user doesn't have local files enabled or doesn't have the music files, it will just play the default track instead.