Trouble passing variable to show command.

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
grand_larson
Newbie
Posts: 2
Joined: Sat Mar 11, 2023 4:28 pm
Contact:

Trouble passing variable to show command.

#1 Post by grand_larson »

Hello all. I need assistance parsing an XML file and passing the tags as variables to show different images. I am able to parse the tags in an XML file and store it in a variable. I want to then take that variable and show an image. In the example below, the xml has the tag background with the value Autumn_bg. I then store that in the variable background and try to pass that variable to the show command, but all I get is the default eileen background. I threw in the D "[background]" line just to confirm that the the variable is being stored properly. Any ideas how to pass a variable to show an image. I have tried a dozen different ways and its not working.

image Autumn_bg = im.Scale("Autumn_bg.jpg", 1920, 1080)
define D = Character("D")

label start:
python:
import xml.etree.ElementTree as ET
tree = ET.parse(renpy.loader.transfn("xml/test.xml"))
background = tree.find('background')
background = background.text
if background == "Autumn_bg":
show background
D "[background]"

return

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

Re: Trouble passing variable to show command.

#2 Post by Ocelot »

show expression background as background
https://www.renpy.org/doc/html/displayi ... expression
< < insert Rick Cook quote here > >

grand_larson
Newbie
Posts: 2
Joined: Sat Mar 11, 2023 4:28 pm
Contact:

Re: Trouble passing variable to show command.

#3 Post by grand_larson »

Ocelot you are a genius. You have no idea how long I racked my brain trying to figure this out. Thank you so much.

Post Reply

Who is online

Users browsing this forum: No registered users