What's optimal here? I pretty much know what I'm doing with internally stored images (on Twine 1/sugarcane) but I'm looking to make an adventure game with lots of different images in it. Is it best to store the files externally in this case to minimise the download size of the game?
If so, how do I do this? Is it best to use a cloud drive or can I link straight to pinterest for instance?
The setup is the same whether you plan on serving your project from a website or making it available for downloading as an archive—i.e. 7z, ZIP, RAR, etc.
Make a new directory within the directory which contains the compiled HTML file—e.g. images—and place your images within it. Then, to reference the images in your project, you'd simply do something like the following:
Unless specifically allowed by the website hosting the resources, hotlinking to resources on third-party websites is usually heavily frowned upon. Don't be "that guy".
It's free to use.
TME, I'm pretty sure your answer is what I need but I can't quite figure it out yet. Soz!
I created a folder for the game files, created a folder within that for the image files and slung a few pics in there to test. I opened a fresh twine file (in twine 1 with sugarcane) and created a new passage within it referencing - as you showed me - to one of the images. When I go to close the passage it asks 'Do you want to import the image files linked in this passage into the story file?'
I click 'yes' and it comes up with the following error.
'An error occurred while importing an image
Traceback (most recent cal last):
File "storyframe.pyo", line 668, in importImagefile
File "storyframe.pyo", line 702, in openfileasbase64
IO error: [errno 2] no such file or directory:
...under that it has a list of all the files that my test files are in.
Any idea what I'm doing wrong?
Also, do I need to save them as 'whatever.jpeg' or can I just save them as 'whatever'?
Just to clarify, I do have a jpeg in the image folder titled 'cas1'.
So the story is in something like User/Me/Documents/Twine/Gamename
...and the folder containing the images is in the same folder 'Gamename'.
What am I missing?
1. I am leaving the User/Me/Documents/ part out of my example to make it simpler. I am also using Gamename to represent the name of the actual story project file and the generated Story HTML file.
2. Based on your last comment I am assuming that your folder/file structure is as follows. ... where the Gamename folder contains a sub-folder named vt_img, a Story Project file named Gamename.tws and a Story HTML file named Gamename.html which you generated using one of the Build options. And the vt_img sub-folder contains an image named cas1.jpeg
I did not notice before that you are using Sugarcane, that story format has an issue with accessing a locally referenced image file using the [img[fine-name]] based markup. You will need to use a HTML image element like the following:
Or you could switch to the SugarCube which does support using [img[fine-name]] based markup to reference local image files.
A curious thing; another file appeared next to the gamename.html file and it seems identical bar the name 'tmpeseupu' (html).
I'm pretty sure I didn't name it. What the hell is it!? :S
I've had a fiddle with it and I'm stumped. I still have only the broken image icon. Is there something I might be missing that links the image with the game?
I'll attempt it in sugarcube when I get a chance, see if that works.
At the very least, that would show you what URL is being used, so you'd know where to look.
Does that explain what I'm doing wrong?
I've dabbled with T2 but stuck with T1 because I'm not keen on everything being stored in my browser. I don't have a problem with images being referenced from an outside source like a cloud drive or similar (I forget the generic term for that - host?) but I like the game stored on my hard drive. I thought we were attempting to reference images in a file within the same file as the game files (tws & html) all stored on my hd.
Not if you've followed greyelf's examples.
Assuming that all of the following are true:
I'm attaching a ZIP archive of a working example project to this post which shows both image markups—built in SugarCube 2, but the HTML image markup should work even in the vanilla story formats.
Could you try extracting it and testing it out? First, simply open the pre-built HTML file. After that, build the project yourself, saving the HTML within the same directory. Do both work for you?
Also, have you tried opening the built HTML files in a different browser than you normally use?
Within a sub-directory of the directory containing the built HTML files, yes.
I tried the example and it works fine so I think that rules out any problem with my browser and clearly implicates me as the problem. Who would have thought that?
I'm stumped. I haven't misspelled anything as I copied what I needed.
It seems really straight forward to me so you guys must be stuck in a permanent facepalm by now. Soz for that.
Oh well, feel free to leave me to work this out from here as it seems you've done all that can be done. I'm sure I'll have a moment of revelation soon enough.
Regardless, at least it's working for you now. So, woot!