Retrieving cached images?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Saltome
Veteran
Posts: 244
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Retrieving cached images?

#1 Post 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?
Deviant Art: Image
Discord: saltome
Itch: Phoenix Start

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: Retrieving cached images?

#2 Post by AxemRed »

What's the advantage of using integers instead of strings?

User avatar
Saltome
Veteran
Posts: 244
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: Retrieving cached images?

#3 Post 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.
Deviant Art: Image
Discord: saltome
Itch: Phoenix Start

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Retrieving cached images?

#4 Post 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.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users