Page 1 of 1

Onlayer with a variable?

Posted: Tue Jan 03, 2017 6:47 am
by Onishion
What I'd like to do is set a variable, and then show/hide images using that variable.

Code: Select all

config.layers = [ 'master', 'MyUniqueLayer2', 'MyUniqueLayer1', 'transient', 'screens', 'overlay' ]
default Var = "MyUniqueLayer1"

if X:
    $ Var = "MyUniqueLayer1"
else:
    $ Var = "MyUniqueLayer2"
    
show MyImage onlayer Var
The above code does not work, says that the layer Var doesn't exist, so the straightforward method doesn't work, but is there some way that I can do this, or am I forced to put if/then chains on each time I show/hide it so that it activates a different "show" or "hide" command with the right layer?

Re: Onlayer with a variable?

Posted: Tue Jan 03, 2017 8:46 am
by xela

Code: Select all

$ renpy.show("MyImage", layer=Var)

Re: Onlayer with a variable?

Posted: Tue Jan 03, 2017 11:19 am
by Onishion
Ok, that may work out for my purposes, I'll give it a shot. Thanks!

And just to check, if I want to put an "at Transform" property and in there, like

Code: Select all

show MyImage at MyTransform onlayer Var:
    zoom .5
at_list = [MyTransform"] seems to work so far, but what would be the syntax for adding basic transforms to it like zoom .5, pos 150? Do I have to bundle all that into a prepackaged transform to access them?

Re: Onlayer with a variable?

Posted: Tue Jan 03, 2017 12:29 pm
by xela

Code: Select all

$ renpy.show("MyImage", layer=Var, at_list=[Transform(zoom=.5, xpos=500)])

Re: Onlayer with a variable?

Posted: Tue Jan 03, 2017 6:11 pm
by Onishion
Awesome, thank you.