Help with 'renpy.loadable' (SOLVED)

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
EHCB
Newbie
Posts: 5
Joined: Tue Jun 19, 2012 7:17 am
Location: Hertfordshire
Contact:

Help with 'renpy.loadable' (SOLVED)

#1 Post by EHCB »

Hi all, I was hoping someone could help me with using this under-documented function

What I'm trying to do is set up a system whereby I can quickly drop looping animations into the game without defining each one through ATL. I can get a DynamicDisplayable to run through numbered files in a folder, but I need it to return to frame 1 when there's no more frames left. I've attempted to create an 'if' block just before the frame's filename is returned that resets the CurrentFrame int to 1 once the animation completes (relevant code between all the #'s below)

Code: Select all

init python:

    def AnimationFrame(st, at):
    
        global CurrentFrame
        global CurrentFrameString
        global CharName
        global ExpressionName
        
        if st > 0.7:
        CurrentFrame = CurrentFrame+1
            CurrentFrameString = str(CurrentFrame).zfill(5)
            
##################################################################################################################
                if renpy.loadable("images/CHARS/[CharName]/[ExpressionName]/[ExpressionName]_[CurrentFrameString].png")==False:
                CurrentFrame = 1
                CurrentFrameString = str(CurrentFrame).zfill(5)[/b]
####################################################################################################################

        return "CHARS/[CharName]/[ExpressionName]/[ExpressionName]_[CurrentFrameString].png", 0.7
               
        
init:

    image Portrait = DynamicDisplayable(AnimationFrame)



label start:

    scene bg room
    show Portrait
    "Hello, world."
    return

I think I'm using 'renpy.loadable' wrong because it seems to be returning false every time. Does anyone have the specifics on how I should enter the filepath?

Some variations I've already tried are:

Code: Select all

renpy.loadable("game\images/CHARS/[CharName]/[ExpressionName]/[ExpressionName]_[CurrentFrameString].png")

renpy.loadable("[ExpressionName]_[CurrentFrameString].png")  ##the documention just says 'a file that can be loaded from an archive' so I thought maybe I didn't need to specify folders at all)
Last edited by EHCB on Thu Mar 01, 2018 3:35 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2498
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Help with 'renpy.loadable'

#2 Post by Ocelot »

First of all: file handling is slow. I recommend to imagine if there is a pause 0.5 after renpy.loadable call. If it is not a problem to you then continue.

RenPy only does varaible substitution only when it displays something. If you want to use variable as part of string, you should build it yourself (using one of multitude ways existing in python).
< < insert Rick Cook quote here > >

User avatar
EHCB
Newbie
Posts: 5
Joined: Tue Jun 19, 2012 7:17 am
Location: Hertfordshire
Contact:

Re: Help with 'renpy.loadable'

#3 Post by EHCB »

Thanks, that did it!

And you were right, it caused a really unacceptable lag so it looks I'm going to have to try another solution.

Thanks again for your help!

Post Reply

Who is online

Users browsing this forum: Google [Bot]