Page 1 of 1

Retrieving cached images?

Posted: Wed Feb 03, 2016 8:41 am
by Saltome
Hii... It's me again. ^^"
If you don't mind, I'd like to ask a question.

Are there ways to retrieve a cached image by integer?

I've already used two ways to do similar things, in the past.
Like naming the actual files as the corresponding integers, then I can convert the integer to a string and it accesses the file directly from the integer. That does make the filenames harder to understand though.

And I've also used a list of the filenames, and pass the index to it to get the actual filename. Which works, except it's additional work, and feels redundant since renpy already caches the images.

...Now that I think about it, though, I haven't seen anything to suggest that renpy even assigns an integer id to images.

Does any of you have any thoughts about this?

Re: Retrieving cached images?

Posted: Wed Feb 03, 2016 2:42 pm
by AxemRed
What's the advantage of using integers instead of strings?

Re: Retrieving cached images?

Posted: Wed Feb 03, 2016 3:44 pm
by Saltome
Well, in most cases integers require less memory. Which also leads to performance increase.
As far as normal use of renpy goes it really isn't worth worrying about.
But if you go and make something more intensive, it slowly adds up.

Re: Retrieving cached images?

Posted: Wed Feb 03, 2016 4:28 pm
by PyTom
I think there's a faulty premise here. Ren'Py uses filenames, not integers, to represent images.

in general, this is a case of premature optimization. A VN has a lot of things that take up memory - images, music files, etc. (Images have to be stored in RAM at 4 bytes per pixel, while the buffering of a music file will take up .5 MB per track.) Unless you're doing something completely absurd involving generated code, saving a few bytes per show and hide statement won't matter.