Is it possible to use a variable when "show" ing something?
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.
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.
- zankizuna
- Veteran
- Posts: 416
- Joined: Fri May 04, 2012 2:20 am
- Projects: Softwar
- Deviantart: raseru09
- itch: ZanKizuna
- Location: Manilaaaaaaaa
- Contact:
Is it possible to use a variable when "show" ing something?
I would like to show an image, but I want it to vary
depending on a condition cited before the show statement.
I know I can just make labels for so many show statements,
but I want to make the program not code heavy, coz it'd kinda look ugly that way imo.
there is supposed to be like, about 100 or over 100 conditions
in short I want to make it something like this, please tell me how to do it right..
image ImageA=("ImageA.png")
image ImageB=("ImageB.png")
image ImageC=("ImageC.png")
image ImageD=("ImageD.png")
*... and so on...*
if (x==1):
$ variable=ImageA
elif (x==2):
$ variable=ImageB
elif (x==3):
$ variable=ImageC
elif (x==4):
$ variable=ImageD
*.... and so on...*
*some more codes*
show [variable] at position2
^
just a pseudocode sort of thing of what I want to happen...
I know this code won't work, please tell me how to do it correctly.
I just want to reduce the show statements...
Thanks!
depending on a condition cited before the show statement.
I know I can just make labels for so many show statements,
but I want to make the program not code heavy, coz it'd kinda look ugly that way imo.
there is supposed to be like, about 100 or over 100 conditions
in short I want to make it something like this, please tell me how to do it right..
image ImageA=("ImageA.png")
image ImageB=("ImageB.png")
image ImageC=("ImageC.png")
image ImageD=("ImageD.png")
*... and so on...*
if (x==1):
$ variable=ImageA
elif (x==2):
$ variable=ImageB
elif (x==3):
$ variable=ImageC
elif (x==4):
$ variable=ImageD
*.... and so on...*
*some more codes*
show [variable] at position2
^
just a pseudocode sort of thing of what I want to happen...
I know this code won't work, please tell me how to do it correctly.
I just want to reduce the show statements...
Thanks!
Last edited by zankizuna on Wed Apr 06, 2016 2:27 am, edited 1 time in total.
Re: Is it possible to use a variable when "show" ing somethi
Look into ConditionSwitch...
- zankizuna
- Veteran
- Posts: 416
- Joined: Fri May 04, 2012 2:20 am
- Projects: Softwar
- Deviantart: raseru09
- itch: ZanKizuna
- Location: Manilaaaaaaaa
- Contact:
Re: Is it possible to use a variable when "show" ing somethi
Ahhhh! Thanks! so....
All I have to do is make all Images go like this??
image Images= ConditionSwitch(
"Image == 'A'", "ImageA.png",
"Image == 'B'", "ImageB.png",
"Image == 'C'", "ImageC.png",
"Image == 'D'", "ImageD.png",
)
$Image=A
show Images at position2
Thanks a lot!
All I have to do is make all Images go like this??
image Images= ConditionSwitch(
"Image == 'A'", "ImageA.png",
"Image == 'B'", "ImageB.png",
"Image == 'C'", "ImageC.png",
"Image == 'D'", "ImageD.png",
)
$Image=A
show Images at position2
Thanks a lot!
Re: Is it possible to use a variable when "show" ing somethi
Yup, and if you have that many images, you might want to consider layering multiple images, like faces/hair/clothing over a body to reduce redundancy, up to you though.
- zankizuna
- Veteran
- Posts: 416
- Joined: Fri May 04, 2012 2:20 am
- Projects: Softwar
- Deviantart: raseru09
- itch: ZanKizuna
- Location: Manilaaaaaaaa
- Contact:
Re: Is it possible to use a variable when "show" ing somethi
ah... as of that... I need plenty of unique objects for my 'VN'...
actually It's more of a game hahaha
actually It's more of a game hahaha
- korova
- Veteran
- Posts: 217
- Joined: Sat Jun 27, 2009 5:15 pm
- Completed: Ivy, Chocolate, Time, Clair Obscur
- Projects: Writing exercises, The House [Nano18]
- Tumblr: korova08
- itch: korova
- Location: Normandie, France
- Contact:
Re: Is it possible to use a variable when "show" ing somethi
I think from the latest version of Renpy, you can also try something like that
and then during your game you just change the variable "letter", and the image Images will change accordingly.
(I use something like that in the last VN I'm -still- working on)
source : https://www.renpy.org/doc/html/changelo ... mic-images
Code: Select all
default letter = "A"
image Images = "image[letter].png"(I use something like that in the last VN I'm -still- working on)
source : https://www.renpy.org/doc/html/changelo ... mic-images
- zankizuna
- Veteran
- Posts: 416
- Joined: Fri May 04, 2012 2:20 am
- Projects: Softwar
- Deviantart: raseru09
- itch: ZanKizuna
- Location: Manilaaaaaaaa
- Contact:
Re: Is it possible to use a variable when "show" ing somethi
wow, thanks a lot, everyone! very useful responses!
learned some stuff
learned some stuff
- zankizuna
- Veteran
- Posts: 416
- Joined: Fri May 04, 2012 2:20 am
- Projects: Softwar
- Deviantart: raseru09
- itch: ZanKizuna
- Location: Manilaaaaaaaa
- Contact:
Re: Is it possible to use a variable when "show" ing somethi
ummm...If I may ask another question...
is this possible for 'at' codes too?
like ...
$positionA=Position(xpos=0.3,ypos=0.5)
$positionB=Position(xpos=0.7,ypos=0.5)
default position =positionA
show ImageA at [position] with move
??
this doesn't work
probably need an alternative
is this possible for 'at' codes too?
like ...
$positionA=Position(xpos=0.3,ypos=0.5)
$positionB=Position(xpos=0.7,ypos=0.5)
default position =positionA
show ImageA at [position] with move
??
this doesn't work
Re: Is it possible to use a variable when "show" ing somethi
You should be able to just type "show ImageA at postion" No brackets needed.
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Is it possible to use a variable when "show" ing somethi
You shouldn't use a statement that isn't listed on the official document.
'Position' is deprecated and no longer documented. Transform or ATL https://www.renpy.org/doc/html/atl.html should be used instead.
'Position' is deprecated and no longer documented. Transform or ATL https://www.renpy.org/doc/html/atl.html should be used instead.
- zankizuna
- Veteran
- Posts: 416
- Joined: Fri May 04, 2012 2:20 am
- Projects: Softwar
- Deviantart: raseru09
- itch: ZanKizuna
- Location: Manilaaaaaaaa
- Contact:
Re: Is it possible to use a variable when "show" ing somethi
oh umm... nvm about the last question
I used a variable like this:
$variablexpos=0.25
show Something with move:
xpos variablexpos
ypos 0.4
.. yeah something like that.
$variablexpos=0.25
show Something with move:
xpos variablexpos
ypos 0.4
.. yeah something like that.

