expected statement error

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
Cristiander
Regular
Posts: 26
Joined: Sat Mar 04, 2017 8:19 am
Contact:

expected statement error

#1 Post by Cristiander » Sat Jan 13, 2018 5:40 am

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?

User avatar
Remix
Miko-Class Veteran
Posts: 788
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I cannot draw very well)
Projects: An un-named 3d anime based trainer game
Contact:

Re: expected statement error

#2 Post by Remix » 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?

Cristiander
Regular
Posts: 26
Joined: Sat Mar 04, 2017 8:19 am
Contact:

Re: expected statement error

#3 Post by Cristiander » Sat Jan 13, 2018 4:42 pm

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?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1226
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: expected statement error

#4 Post by xavimat » Sat Jan 13, 2018 7:19 pm

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.
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
unknown [Sci-Fi - mystery - computer]
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Cristiander
Regular
Posts: 26
Joined: Sat Mar 04, 2017 8:19 am
Contact:

Re: expected statement error

#5 Post by Cristiander » Sat Jan 13, 2018 7:26 pm

Yeah. I looked into the transforms and I defined moveinleft and moveoutleft. They work fine.
Thanks :)

Cristiander
Regular
Posts: 26
Joined: Sat Mar 04, 2017 8:19 am
Contact:

[solved] Expected statement error

#6 Post by Cristiander » Sat Jan 13, 2018 7:28 pm

Cristiander wrote:
Sat Jan 13, 2018 5:40 am
Last edited by Cristiander on Sat Jan 13, 2018 8:05 pm, edited 1 time in total.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1226
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: expected statement error

#7 Post by xavimat » Sat Jan 13, 2018 7:29 pm

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.
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
unknown [Sci-Fi - mystery - computer]
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: No registered users