Ren'Py Renpy expected statement error

JakooTremolo

New Member
Sep 9, 2022
4
1
Hello,could someone please help me with this code?I´m a total beginner at Renpy.I wanted to create the effect of the camera showing the picture with character from bottom to top its done in visual novels, at introduction with new characters.

Code:
define k = Character("kk")

image picture_1 = "FIRST_DAY_MORNING_SCENE_54p_introduce.jpg"

image picture_2 = "FIRST_DAY_MORNING_SCENE_52p_a and.jpg"



label start:



scene picture_1



yalign 1.0

ease 5.5

yalign 0.0



k "test"



scene picture_2



k "test"



return
I created new project for that effect to avoid messing up my original is the error:


Code:
 [code]

I'm sorry, but errors were detected in your script. Please correct the

errors listed below, and try again.


File "game/script.rpy", line 14: expected statement.

    yalign 1.0

            ^
File "game/script.rpy", line 15: expected statement.

    ease 5.5

          ^

File "game/script.rpy", line 16: expected statement.

    yalign 0.0

            ^
Thanks for the help
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
4,962
7,278
My guess is an indentation issue. That label start with nothing past it looks so wrong that I'd be surprised if it didn't return any error.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,560
2,177
There seems to be a mix of things here.

At first glance, the first one is an indenting problem.

RenPy, like python, relies on indentation to effectively say "these options/commands belong to that command".
General rule of thumb, any statement that ends in a colon ( : ) - the options/line(s) below it need to be indented.

The usual convention is that indenting is 4 spaces.
Most "good" text editors will automatically convert pressing <TAB> to being 4 spaces (or at least have it as an option).
RenPy doesn't like <TAB> so make sure you're using an editor which behaves properly.

The second issue is that your yalign and ease transitions should probably be parameters to the scene statement. There's a few ways to do transitions in RenPy, so it's not automatically an error - but I think that's what it's picking up on. If that is the case though, you need a colon at the end of the scene statement.

I'd expect your current code to look more like:

Python:
define k = Character("kk")

image picture_1 = "FIRST_DAY_MORNING_SCENE_54p_introduce.jpg"
image picture_2 = "FIRST_DAY_MORNING_SCENE_52p_a and.jpg"

label start:

    scene picture_1:
        yalign 1.0
        ease 5.5
        yalign 0.0

    k "test"

    scene picture_2
    k "test"

    return

Whilst not a problem, I'd also suggest using either with fade or with dissolve on each and every scene line. Dissolve by default, where just swapping from one image to another and Fade for changing locations. It's a small touch, but your game will appear a little more polished and it's a good habit to pick up from the start.

As an aside, another thing to note is that transitions that take time (like your ease 5.5) won't pause the game to let the image do its animation. That's a good thing mostly. But unless the player is going to spend more than 5.5 seconds reading k "test" your game is likely to continue before the animation has fully played out. You probably want to add a pause statement after showing the animation. Personally, I would always make it a little shorter the animation - but that's a personal preference. The more text after the scene, the shorter that pause needs to be.

Something like:
Python:
    scene picture_1:
        yalign 1.0
        ease 5.5
        yalign 0.0

    pause 4.5

    k "test"

btw. NEVER, EVER use $ renpy.pause(hard=true). You'll see it used occasionally. It forces a pause. Except it doesn't quite work how developers think it does and can lead to some very unexpected results (especially if a player has switched on "auto-forward"). Players tend to hate it when they are forced to wait too. So again, start with good habits... never use them.
 
Last edited: