Question about loading images, Twine sugarcube

Please specify version and format if asking for help, or apply optional tags above:
Twine Version: 2.3.8
Story Format: Sugarcube v2.31.1
I have created my first interactive story.
I used the below code to add photos and sounds to the story.

<img src=“img/Campsite.png” alt=“A photo of a campsite” / > (no space at the end, if i remove it you see a broken image as below :slight_smile:)

A photo of a campsite

<<cacheaudio “maze” “aud/maze.mp3”>> (in storyInit passage) the <

I have saved the game to a folder on my desktop. Inside is the HTML game file and the img and aud folder containing all the media used. On my laptop this all works as expected.

I have shared the zipped folder with some friends to test out and none of the photos/audio worked until they placed the folder onto their desktop. It first saved the folder in the downloads.
Then after that they had moved it they had no issues.

Have I done something wrong? I thought a relative path didn’t matter where the folder was located.

The most likely possibility is that they’re trying to play the game within the ZIP file. If that’s the case, then they’ll need to extract the files to somewhere on their computer in order to play it. The browser won’t be able to access the other files if they’re still inside the ZIP file.

A less likely issue could be that it’s in a “protected” folder, which the operating system isn’t letting the browser access for some reason. Extracting the files to a non-protected folder, such as to a “C:/Games/MyGame/” folder they’ve created, should fix the problem.

Secondly, audio may not play if you try to start it before the user has interacted with the web page, due to browser security reasons. The easiest way around that is to put up some sort of “splash screen”, where you show the game’s logo or whatever, and they have to click something to go to the first page where the music starts.

Hope that helps! :smiley:

P.S. On this forum you should put any code within a “Preformatted text” block using the </> button, otherwise it may not display properly.


Thanks for the reply, I think you may be right. I have managed to test it myself on another computer and it all worked fine.

Can I also say thanks as I have used some code from your sample code document in my game. Really appreciate your time and effort.

No problem. Glad I could help. :smiley: