Page 1 of 1

expected statement error

Posted: Sat Jan 13, 2018 5:40 am
by Cristiander
Hello. I'm running into this error and I don't understand where the problem is.

Code: Select all

label transition_label:
    if screen_on:
        linear 1.0 screen_x 1.0
        linear 1.0 screen_x 1.0
        $ screen_on= False
    else:
        linear 1.0 screen_x 0.0
        linear 1.0 screen_x 0.0
        $ screen_on= True
    return
    
The role of the label is to change position of a screen so that I have a smooth transition.

But when I run the code it tells me

Code: Select all

File "game/script - sprites.rpy", line 118: expected statement.
    linear 1.0 screen_x 1.0
            ^

File "game/script - sprites.rpy", line 119: expected statement.
    linear 1.0 screen_x 1.0
            ^

File "game/script - sprites.rpy", line 122: expected statement.
    linear 1.0 screen_x 0.0
            ^

File "game/script - sprites.rpy", line 123: expected statement.
    linear 1.0 screen_x 0.0
            ^

Ren'Py Version: Ren'Py 6.99.12.4.2187
I don't understand what the problem is. Is it not posible to use linear on custom variables?

Re: expected statement error

Posted: Sat Jan 13, 2018 9:58 am
by Remix
Though you could *possibly* utilize AnimatedValue to linearly adjust the value over time, I am pretty sure there are other, simpler ways to accomplish what you want.
If you are just applying a transform when showing or hiding the screen, perhaps the on show: and on hide: event blocks within an ATL would be best.
What are you trying to do?

Re: expected statement error

Posted: Sat Jan 13, 2018 4:42 pm
by Cristiander
Remix wrote: Sat Jan 13, 2018 9:58 am Though you could *possibly* utilize AnimatedValue to linearly adjust the value over time, I am pretty sure there are other, simpler ways to accomplish what you want.
If you are just applying a transform when showing or hiding the screen, perhaps the on show: and on hide: event blocks within an ATL would be best.
What are you trying to do?
I have a button that I want to change whether information is shown or not.

The transition label has the role of transitioning the information on and off screen. The information is a separate screen. The x and y aligns are at 0.0 so by changing the anchors I figured the screen would move in and out.

Is there a better way of doing this?
How do show and hide events work?

Re: expected statement error

Posted: Sat Jan 13, 2018 7:19 pm
by xavimat
Cristiander wrote: Sat Jan 13, 2018 5:40 am

Code: Select all

label transition_label:
    if screen_on:
        linear 1.0 screen_x 1.0
        linear 1.0 screen_x 1.0
        $ screen_on= False
    else:
        linear 1.0 screen_x 0.0
        linear 1.0 screen_x 0.0
        $ screen_on= True
    return
    
This code has no meaning in renpy. Actually, renpy label code is different from renpy screen code and from renpy ATL code.
"linear" is used inside ATL code (when defining transforms or in show block). In your code I assume that "screen_x" is a variable you have defined somewhere and you want "linear" to change the value of that variable, "linear" can't be used for that.

You can, on the other hand, define transforms that accept arguments, and show the main elements of a screen with that transform.

Re: expected statement error

Posted: Sat Jan 13, 2018 7:26 pm
by Cristiander
Yeah. I looked into the transforms and I defined moveinleft and moveoutleft. They work fine.
Thanks :)

[solved] Expected statement error

Posted: Sat Jan 13, 2018 7:28 pm
by Cristiander
Cristiander wrote: Sat Jan 13, 2018 5:40 am

Re: expected statement error

Posted: Sat Jan 13, 2018 7:29 pm
by xavimat
An example of what I was saying:

Code: Select all

label start:
    scene black
    show screen test
    "bla"
    show screen test(1.0)
    "bla2"
    show screen test(0.5)
    "bla3"
    hide screen test
    "bla4"
    return

transform my_t(x):
    linear 1.0 xalign x

screen test(x=0.0):
    frame:
        at my_t(x)
        label "Hello world!"
You can show a screen that is already showed, and the new values pass to the transform, that adjusts (with "linear") to the new position.