variable in filename of an image

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
User avatar
Riwer
Newbie
Posts: 15
Joined: Mon Mar 25, 2013 9:25 am
Contact:

variable in filename of an image

#1 Post by Riwer »

I defined a image like this:

Code: Select all

image Selina bik head1 = LiveComposite(
                (496,700),
                (0, 0), path+bik+ext,
                (0, 0), "characters/Selina/head1.png")

Code: Select all

$ path = "characters/Selina/"
$ ext = ".png"
$ bik = "01"
The variable bik update her data when I press a specific button in a screen. (to change 01 to 02,03 etc etc)

When I control the variable, the variable bik change her data good with the buttons, but the image dont update her "bik part".

If bik by default is 01, always when I type:

Code: Select all

Show Selina bik head1 
the result is the image: characters/Selina/01.png

When I press a button to change bik to 02, (and I type other show for update the image, the result is the same, but if I check the variable, bik is 02, but the image always is 01.png... why?

User avatar
Suwamoto
Regular
Posts: 66
Joined: Wed Sep 05, 2012 7:36 am
Contact:

Re: variable in filename of an image

#2 Post by Suwamoto »

Instead of declaring the variables like this

Code: Select all

$ path = "characters/Selina/"
$ ext = ".png"
$ bik = "01"
Try this

Code: Select all

init python:
	path = "characters/Selina/"
	ext = ".png"
	bik = "01"
I am not sure why but I think Ren'py's LiveComposite just updates the stuffs that were declared under a python init block oxo

User avatar
Riwer
Newbie
Posts: 15
Joined: Mon Mar 25, 2013 9:25 am
Contact:

Re: variable in filename of an image

#3 Post by Riwer »

Thanks for the help, but didn't work D:

User avatar
Suwamoto
Regular
Posts: 66
Joined: Wed Sep 05, 2012 7:36 am
Contact:

Re: variable in filename of an image

#4 Post by Suwamoto »

Mhm and if you change the LiveComposite to this?

Code: Select all

init:
    image Selina head1 = LiveComposite(
                (496,700),
                (0, 0), "%s%s%s"%(path, bik, ext),
                (0, 0), "characters/Selina/head1.png")
And if that still doesn't work, how about

Code: Select all

init python:
    def draw_selina(st, at):
        return LiveComposite(
            (496,700),
                (0, 0), "%s%s%s"%(path, bik, ext),
                (0, 0), "characters/Selina/head1.png")
            ),.1

init:
    image Selina head1 = DynamicDisplayable(draw_selina)

User avatar
Riwer
Newbie
Posts: 15
Joined: Mon Mar 25, 2013 9:25 am
Contact:

Re: variable in filename of an image

#5 Post by Riwer »

Suwamoto wrote:Mhm and if you change the LiveComposite to this?

Code: Select all

init:
    image Selina head1 = LiveComposite(
                (496,700),
                (0, 0), "%s%s%s"%(path, bik, ext),
                (0, 0), "characters/Selina/head1.png")
Don't work, no errors ;_;
Suwamoto wrote: And if that still doesn't work, how about

Code: Select all

init python:
    def draw_selina(st, at):
        return LiveComposite(
            (496,700),
                (0, 0), "%s%s%s"%(path, bik, ext),
                (0, 0), "characters/Selina/head1.png")
            ),.1

init:
    image Selina head1 = DynamicDisplayable(draw_selina)
When run, invalid syntax in: ),.1

If I delete ),.1, At least I get a error when the game try to load the function:

TypeError: 'MultiBox' object is not iterable

And thanks for your help!! >_<


EDIT: asdfasdfaa works!
(0, 0), "characters/Selina/head1.png"),.1 <----
Thanks! ^ô^

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]