Not a Displayable Error When Using Custom Function

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
Poorman65
Newbie
Posts: 12
Joined: Fri Apr 20, 2018 2:36 am
Contact:

Not a Displayable Error When Using Custom Function

#1 Post by Poorman65 » Wed May 23, 2018 1:14 am

I'm trying to take some repetitive stuff and break it out into reusable pieces. I have tried a few different approaches but the current one is to write functions that will take care of multiple steps. Unfortunately I am get an error on what I expected would be a straight forward first step.

Code: Select all

File-MyScreens.rpy

screen timedDisplay(timerLen, *displayables):
    zorder 1000
    for displayablesName in displayables:
        add displayablesName
    timer timerLen action Hide("timedDisplay") repeat False
    key "dismiss" action [[]]
And in MyFunctions.rpy I've defined a function which calls the Screen as follows:

Code: Select all

File - MyFunctions.rpy

init python:
    def showTimedDisplayables(timerLen, *displayables):
        renpy.show_screen("timedDisplay", timerLen, displayables)
In my script.rpy file I have the following

Code: Select all

        image Riley Riley_Look = "Ch 01/Assets/Overlays/Vixens/Riley/Riley - Looked - Reaction.png"
        $ renpy.show_screen("timedDisplay", 2, "Riley Riley_Look")
        "..."
        $ showTimedDisplayables(2, "Riley Riley_Look")
        "..."
For some reason it works fine in the first case when the show_screen is called directly. But in the second case when I call the function and have it relay the call to the show_screen, I get an error saying "Exception: Not a displayable:(u'Riley Riley_Look',)"

kivik
Miko-Class Veteran
Posts: 720
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Not a Displayable Error When Using Custom Function

#2 Post by kivik » Wed May 23, 2018 7:04 am

How weird!

Not sure what causes it but basically "Riley Riley_Look" got turned into a unicode string when being parsed through showTimedDisplayables().

I managed to fix it with this:

Code: Select all

add "%s" % displayablesName

Poorman65
Newbie
Posts: 12
Joined: Fri Apr 20, 2018 2:36 am
Contact:

Re: Not a Displayable Error When Using Custom Function

#3 Post by Poorman65 » Wed May 23, 2018 10:37 am

Awesome! That works perfectly! Thank you!!

I was hitting errors with some of the other approaches that I tried where it was complaining about Unicode Strings down deep in the APIs. May be a similar solution in those cases.

One of things I was trying to do was to create my own Statements to handle these patterns. Maybe I'll be able to have it working both with a Statement and a Function like the Renpy stuff does.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Imperf3kt