Proper way to store images or pack files Sugarcube 2. 31. 1

So whenever I try packing my files all into an executable, my friends that play my game demo, only see broken links where my images should be. I’ve tried like 3 different ways, what am I doing wrong?
Would it be easier to just store the files somewhere online?
What are the best methods?
Need a more experienced opinion.
Thanks.

You need to compile the files into the executable, though you may also be able to pack them side by side.

It obviously depends on how you built the executable how you’d do any of this. At that point, you’d likely be better off asking in the help forums or issue tracker of that software frankly, since this isn’t really a feature of Twine, but you can ask it here too, and someone may be able to help.

Edit to clarify. When I say “you’d likely be better off asking” somewhere else, I mean that you’ll likely get better and faster answers in those other communities. Again, you can/should also ask here, but your mileage may vary.

Thank you for the advice!

To answer that we’d need a lot more information. What are you using to pack the files into the executable? What methods have you tried? How are you trying to access the images within your code? What OS are you using?

Without that kind of information we’d just be shooting in the dark.

1 Like

I’ve tried NWJS to compile everything into a folder with an exe. and package.json
and that didnt work (or more likely I did it improperly), so then I tried putting all my pictures on a google drive, and that didnt work.
To clarify ‘it didnt work’ meaning the images were no longer in the game when I sent the game to other people.
No matter what method I tried, the pictures worked on my laptop. Even with storing the images on google drive.
so those are the two methods Ive tried thus far. but Ive tried multiple different versions of both.
I hope that helps.

I could be wrong, but it kind of sounds like maybe your game is still pointing at the image directory on your hard drive. So when you run the game locally, it works for you but not for anyone else.

To test if my theory is right, try removing an image from outside of the image folder in your twine project directory (the one that works when you run the game in the browser, not the one you compiled into the NWJS app). Then run the NWJS app and see if only that one image doesn’t load. If it doesn’t load, that’s your issue.

1 Like

That is the issue. Where is the best place to put it, so it doesn’t end up on your local hard drive.

How are you calling the images right now? If it’s still loading the ones on your hard drive, it sounds like you must be using a full path instead of a relative path (IOW, “C:/Documents/Twine/Stories/images/picture.jpg” instead of just “images/picture.jpg”).

I’ve managed to get my own game engine to work in NWJS and it used relative paths with no fiddling on my part, so it should “just work” if you point it to a relative path.

Oh yes I am using a very specific path. So just make the path more relative so it doesn’t lead all the way back to my hard drive basically?

Yep. Exactly.

If you decide to revisit the online storage option (in case your game size gets too big) I would suggest using imgur. I tried using google drive too for my online stories and peoples where also having broken images but it was all resolved when I moved to imgur.

Never had any problem since but I would still recommend keeping a back up of your images on your computer just in case. :slight_smile:

oh and it’s free so that’s nice lol

Edit: sorry didn’t know it was against the rule, removed it.

That’s hot linking and is actually against imgur’s ToS, so ymmv.

1 Like

Generally speaking, it’s a bad idea to have your images online at a site you don’t own, since this means that the game will likely be totally broken in the future when those images are removed.

I’ve seen plenty of games die this way.

Agreed, that is why I said to keep the image from the game saved in case of that happening. There is also the option to get a free website or blog just to save the image there but I am unsure if there is limit to the amount you can save.

It’s just that sometime game can become quite big if using gif and the likes, imgur seems like a fairly safe option although I will admit if size isn’t a problem then keeping it together is the safest option.

I’d recommend that you almost never use GIFs. They generally have poor compression and tend to damage images due to the limit of 256 colors.

For still photos I’d recommend JPEG. For still images which need sharp edges, such as screenshots of text, I’d recommend PNG. And for animation I’d currently recommend using MP4/H.264 video, since it gets high quality, compression, and compatibility (MP4 is the container format, and H.264 is the video compression format).

I’d only use GIF if I needed an animated image which has a low number of colors and needs sharp edges, such as an animated cartoon or moving text.

That said, if you (Jarrid) switched from using NWJS to Electron, then you could pack the data into an ASAR file. That’s actually what the current version of Twine does.

Hope that helps! :grinning:

1 Like

NW.js allows using a ZIP archive to seamlessly package your project assets into the executable, so the capability is available there too—though I wouldn’t necessarily do that with several gigabytes worth of assets.

Linking the site isn’t against the rules. What you’re suggesting (linking directly to images on imgur’s site) is against their rules. After a month or so, it’ll be replaced with ads.

We allow hotlinking on forums, but hotlinked images cannot be used as content for a website, including blog posts, avatars, site elements, and advertising. You can read our terms of service for more info. If you believe your site has been mistakenly blocked, please contact us for assistance.

source: https://help.imgur.com/hc/en-us/articles/201569776

1 Like

Wow, I didn’t know that. I certainly won’t use them anymore lol. It was the whole point of uploading image there.

Thanks for the info :slight_smile:

between school and work, twines kinda been taking the back seat lately. Just started up again recently, but yes it does help a ton. Thank you very much.

So I still believe this must be the issue, BUT. when I don't make it go all the way back to my computer or C drive the image completely breaks. Is there somewhere I can put my image files on my PC where it will allow me to have a more relative path to displaying the image. Primarily for Chapels <<Say>> macro by the way. sorry I didnt mention that earlier