Formatting in choicescript

I would certainly recommend the above method over images to begin with, but there is a way you can include images in a compiled game.

Visit this website (or any other online image to data uri converter):
http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/

Upload your image as per the instructions and when the process is complete, copy the ‘raw data’ to your clipboard, it should look something like this… (…only it will be A LOT longer!)

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsoAAAHiCAYAAADxgeqGAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAFCOSURBVHhe7d1djB7Xfef53O9i52aBzV7s7GBBYfYmwQL7crebuVhgBiRv9momwQabZBEHE2OHpJFxxpm82vECmUWsSOQoTuDNmHIkc7zJ2KHohkVFkiVGNCmZTTebFBWxqRdKtvnafJ8MkEnO1v

You can then paste that raw data as the *image command’s parameter (instead of a path or url).
data_uri’s are extremely long however, so I suggest always making a seperate scene for each image and using *gosub_scene to include it (so you never have to open it again and it doesn’t bloat your normal scenes).

so in myimage.txt:

*image data:image/png;base64,iVBORw0KGgoAAAAN...etc...
*return

and where you want the image to appear:

*gosub_scene myimage.txt


This is a perfectly acceptable and valid method for displaying images on the web, so don’t be afraid to use it.
It can make images take up more a bit more space though, so it’s worth making sure they’re well optimized before converting them.

Time and ability permitting I would very much like to eventually make the compiler automatically convert any images included in the game to data_uris so you wouldn’t have to this manually.

5 Likes