Howdy! My friend is working on a project that is trying to display images using variables. But in the following code this does not display at all. With the problem displayed very simply.
x = image1
y = x
output y, show image 1
So how does he get the images to properly display?
label start:
# Initial Declaration
image player_initiative_token = "init_head_4.png"
# Transfer From Declaration To Neutral Variable (Does Not Work, Says 'player_initiative_token' Is Undefined.
image initiative_filler = player_initiative_token
# Transfer From Declaration To Neutral Variable Alternative (Does Not Work, Thinks "player_Initiative_token" Is The Image.
image initiative_filler = "player_initiative_token"
return
How do I transfer held image variable into another image variable
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.
Re: On RPG Style Initiative System
What are you trying to achieve?
Some tips:
- image statement is used to declare displayables.
- all the declarations (default/define values for variables, images, screens) are execute befor start of the game no matter where you placed them in script.
So check the tutorial that ships with the engine, some documentation and script samples to fix your code.
https://www.renpy.org/doc/html/index.html
https://www.renpy.org/doc/html/index.ht ... le-scripts
If you need a dynamic image check this
https://www.renpy.org/doc/html/displaying_images.html
https://www.renpy.org/doc/html/displaya ... splayables
https://www.renpy.org/doc/html/changelo ... mic-images
viewtopic.php?f=51&t=19063#p246889
Some tips:
- image statement is used to declare displayables.
- all the declarations (default/define values for variables, images, screens) are execute befor start of the game no matter where you placed them in script.
So check the tutorial that ships with the engine, some documentation and script samples to fix your code.
https://www.renpy.org/doc/html/index.html
https://www.renpy.org/doc/html/index.ht ... le-scripts
If you need a dynamic image check this
https://www.renpy.org/doc/html/displaying_images.html
https://www.renpy.org/doc/html/displaya ... splayables
https://www.renpy.org/doc/html/changelo ... mic-images
viewtopic.php?f=51&t=19063#p246889
Re: How do I transfer held image variable into another image variable
Hi there, thanks for the quick response again Alex, this is a message he wanted me to send you back. Says he's going for a image held in variable he can transfer to other variables
Basically, if I have
image player_initiative_token = "init_head_4.png"
image player_initiative_coin = "init_head_5.png"
image initiative_filler = player_initiative_token
show initiative_filler
Then I want "init_head_4.png" to show up.
image initiative_filler = player_initiative_coin
show initiative_filler
Then I want "init_head_5.png" to show up.
Basically, if I have
image player_initiative_token = "init_head_4.png"
image player_initiative_coin = "init_head_5.png"
image initiative_filler = player_initiative_token
show initiative_filler
Then I want "init_head_4.png" to show up.
image initiative_filler = player_initiative_coin
show initiative_filler
Then I want "init_head_5.png" to show up.
Re: How do I transfer held image variable into another image variable
Sounds like he just wants to do dynamic images by using variables to alter the image being shown?
If that's the case, this may be easier:
I could be mistaken, but the image declaration statement isn't python:
Does not equal to:
What's actually happening is:
Consider this: You can define images with spaces:
There isn't a variable called "eileen happy" with the image stored inside. It's just that there's now a renpy image with the name "eileen happy" with tag "eileen" automatically created.
It can be a bit confusing but anything that's renpy specific language do not behave like python language, and note that any variable declarations within renpy are done with $ (python statement prefix), except for the "default" and "define" statements. So hopefully it'll make sense to your friend soon.
Overall I think what he wants is to look into dynamic images: https://www.renpy.org/doc/html/changelo ... mic-images
If that's the case, this may be easier:
Code: Select all
image player_head = "init_head_[filler].png"
default filler = "4" #make sure this is string
label start:
show player_head # shows init_head_4.png
filler = "5" # immediately changes head to init_head_5.png
Code: Select all
image player_initiative_token = "init_head_4.png"
Code: Select all
$ player_initiative_token = Image("init_head_4.png")
Code: Select all
$ renpy.image("player_initiative_token", "init_head_4.png")
Code: Select all
image eileen = "eileen.png"
image eileen happy = "eileen_happy.png"
It can be a bit confusing but anything that's renpy specific language do not behave like python language, and note that any variable declarations within renpy are done with $ (python statement prefix), except for the "default" and "define" statements. So hopefully it'll make sense to your friend soon.
Overall I think what he wants is to look into dynamic images: https://www.renpy.org/doc/html/changelo ... mic-images
Re: How do I transfer held image variable into another image variable
Great Kivik! So the issue got fixed but a certain part of the problem wasen't covered with your solution. My friend was able to make a work around with your solution.
Re: How do I transfer held image variable into another image variable
I think it's best for your friend to start at a higher level with his questions - as the questions are very specific and detailed, and there may actually be much simpler solutions to his problems if he lets us know the broader picture of what he's trying to achieve.
Sounds like he's making progress but just tell him to bear that in mind
Sounds like he's making progress but just tell him to bear that in mind
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], MSN [Bot]