screen image issue

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
FlipTopBin
Newbie
Posts: 15
Joined: Thu Apr 12, 2018 5:55 am
Contact:

screen image issue

#1 Post by FlipTopBin » Thu Apr 12, 2018 6:14 am

Hi All,

I am trying to write a simple screen which shows an information page for each character/subplot in my novel and it almost but not quite works. Everything is working apart from the icon.

The story name and hint are displayed correctly and change correctly when you hit Prev/Next, the exit button is always displayed and exits the screen. The Prev/Next buttons work, they appear when they should and cause the information to change to different stories. Unfortunatly, the icon gets displayed for the first story then never changes even though I can see that the name of the icon changes correctly. Its like once there is an icon displayed nothing else can override it. I have checked that all the icon names are correct in the other stories by substituting them into the the story at index zero as well.

I am sure I am missing something obvious but I have no idea what so please point out my mistake.

My code:

Code: Select all

screen storyBook(index):
    # Retrieve data about this story
    $ story = storyClass.allStories[index]
    $ icon = story.getIcon()
    $ name = story.getName()
    $ hint = story.getHint()
    $ maxIndex = len(storyClass.allStories) - 1
    
    # show the icon on the left
    add "[icon]" pos (90, 60)
    
    # story name at the top
    hbox:
        pos (540, 60)
        box_wrap True
        text "[name]"
        # bit of debug text just to prove that the icon name was changing correctly
        text " index = [index], icon = [icon]"
    
    # story progress hint underneat
    hbox:
        pos (540, 210)
        box_wrap True
        text "[hint]"
        
    # prev story button as long as there is one
    if index != 0:
        textbutton "Prev":
            pos (540, 610)
            action Show("storyBook", None, index - 1)
    
    # close this screen
    textbutton "Exit":
        pos (790, 610)
        action Hide("storyBook")
        
    # next story button if there is one
    if index < maxIndex:
        textbutton "Next":
            pos (1040, 610)
            action Show("storyBook", None, index + 1)

DannX
Regular
Posts: 99
Joined: Mon Mar 12, 2018 11:15 am
Contact:

Re: screen image issue

#2 Post by DannX » Thu Apr 12, 2018 8:31 am

This is only a guess but I think the problem is you are double interpolating the icon screen variable. If story.getIcon() is a function that returns a string with an image name, you don't need to interpolate it between [] brackets, you can simply do this:

Code: Select all

add icon pos (90, 60)
If you need to show some other kind of value as text on a screen, and it isn't updating correctly, another option is to use .format interpolation.

Code: Select all

text "{}".format(var) 

FlipTopBin
Newbie
Posts: 15
Joined: Thu Apr 12, 2018 5:55 am
Contact:

Re: screen image issue

#3 Post by FlipTopBin » Thu Apr 12, 2018 8:59 am

Star!

add icon pos (90, 60)

did the trick. Thanks for putting me out of my misery so quickly.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]