Using Defined Images in Screens? [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
corny
Regular
Posts: 41
Joined: Sun Sep 18, 2011 1:08 pm
Contact:

Using Defined Images in Screens? [Solved]

#1 Post by corny »

Hi all,

I want to show a pre-defined image on a menu screen. My game has a customizable player avatar, and I want their image to be shown on the menu screen, like this placeholder example:
Image

Here's my problem, though. I can't seem to put images I defined in script.txt there. I can only display them if I directly call the filename, which doesn't work when the player's avatar has to be defined by a ConditionSwitch to be displayed correctly. (I have an if/else code there to be sure something is displayed if this menu is viewed before the avatar is chosen, which functions fine. Don't worry about that part.)

This is the code I'm using to make the character appear on the right, that doesn't work. The stuff on the left is part of the same screen, but I assume it doesn't affect her. Dede is the character in the image above. pc_avatar is defined with the ConditionSwitch, and dede is defined like any regular displayable image would be in the script file, with image dede = "images/dede.png"

Code: Select all

    if avatar_set == True:
        add pc_avatar at float_6
    else:    
        add dede at float_6    
And here's the traceback, saying that pc_avatar is not defined. At the point in the game where I've called this menu to test it, it has been defined. It says the same of dede when that's the only one.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 504, in script
    
  File "renpy/common/000statements.rpy", line 519, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "game/screens.rpy", line 461, in execute
    screen descanta_menu():
  File "game/screens.rpy", line 461, in execute
    screen descanta_menu():
  File "game/screens.rpy", line 516, in execute
    if avatar_set == True:
  File "game/screens.rpy", line 517, in execute
    add pc_avatar at float_6
NameError: name 'pc_avatar' is not defined

I hope it's clear what I'm trying to make happen here. Is there any way to use images defined in script.txt in screens? Let me know!

corny
Regular
Posts: 41
Joined: Sun Sep 18, 2011 1:08 pm
Contact:

Re: Using Defined Images in Screens? [Solved]

#2 Post by corny »

My very smart friend informed me that pc_avatar and dede just needed to be in quotes for them to work. I knew it would be something simple like that :X

Post Reply

Who is online

Users browsing this forum: Google [Bot]