I use script to load certain files in my game. I have an automated telephone voice system that will play sound clips together to form a sentence. Here's a snippet of code to show what I'm doing...

		if ResourceLoader.exists("res://Sounds/Mom/YouHaveReached.wav") && ResourceLoader.exists("res://Sounds/Mom/" + names[1] + ".wav") && ResourceLoader.exists("res://Sounds/Mom/" + names[0] + ".wav") && ResourceLoader.exists("res://Sounds/Mom/" + names[2] + ".wav"):
			var ring = get_node(StreamRing)
			var momvoicemail = load("res://Sounds/Mom/YouHaveReached.wav")
			var formerly = load("res://Sounds/Mom/Formerly.wav")
			var firstnamesound = load("res://Sounds/Mom/" + names[0] + ".wav")
			var lastnamesound = load("res://Sounds/Mom/" + names[1] + ".wav")
			var maidennamesound = load("res://Sounds/Mom/" + names[2] + ".wav")

It works fine in Windows exports, but I think since the file system gets changed in the HTML5 export, this doesn't work. I think it's an issue with using variables to designate the file name instead of a constant path. What would be a better way of referencing/loading a certain sound with code and variables to customize the output? I hope I was clear enough explaining this. Let me know if you need more detail.

Are the file path names exactly the same as the directories and file names in Windows? When loaded into a .pck file it becomes case sensitive, so that could be why it's not working in HTML5. That said, it should also not work in Windows if that was the issue...

With the code snippet above, do you know if the if condition is working or not? You can test by adding a print statement or something in the condition and then checking the console, I think. I think the HTML5 builds should output to the web browser console but I'm not 100% certain. Something else you can do is have a ColorRect node or something that will be easily visible and then toggle it's visibility if the condition is true/false instead, if a print statement doesn't work.

@TwistedTwigleg thanks for the reply. The names are correct, because as you said it wouldn't work in Windows. I removed the if statement and it still worked in Windows but not in HTML5. I'm going to keep playing around with it, but I figured I'd have to come up with a different way of loading these files and was wondering if the way I'm doing it is "weird" or if there's a more standard way without adding together strings like that.

Ok, I think I've narrowed down the issue. It's not what I thought. Parsing together the file paths works fine when I isolate that, but it breaks down when I retrieve info from my speech file. I have a JSON that contains all of the words and sentences with text to display on the screen, filenames, and various attributes of how I want the sound to play. It seems that the JSON isn't loading or the dictionary that's parsed from the JSON isn't being read properly. Any ideas on what could go wrong loading a JSON with HTML export? Here's my code for loading the JSON:

extends Node

var SpeechPath = "res://Data/Speech.json" var DungeonSpeechPath = "res://Data/DungeonSpeech - Sheet1.json" var SpeechData = {} var DungeonData = {}

func _ready(): SpeechData = Load_JSON(SpeechPath) DungeonData = Load_JSON(DungeonSpeechPath)

func Load_JSON(path): var speech_file = File.new() speech_file.open(path, File.READ) var speech_json = JSON.parse(speech_file.get_as_text()) speech_file.close() var data = speech_json.result return data

Try printing out the file as text, then after the JSON.parse, and then the result. It may be that the file is malformed somehow, and that the json parser is not working.

I figured it out. I needed to add *.json to resources when exporting to HTML5. Thanks for the help!

a year later