Expected Statement Error [SOLVED]

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
Gushi
Newbie
Posts: 24
Joined: Sun Apr 01, 2018 3:25 pm
Projects: Project 4th Wall
itch: https://umberbridge.
Contact:

Expected Statement Error [SOLVED]

#1 Post by Gushi »

So I'm doing a Rock, Paper, Scissors like game and I keep getting this error

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/True_end.rpy", line 479: expected statement.
    elif result == "scissors":
                ^
this is the code that it's talking about

Code: Select all

    if result == "paper":
        u "HAHAHAHA!{nw}"
        play sound "UI_Quirky33.mp3"
        show rom scare:
            linear 0.090 xoffset -10 
            linear 0.090 xoffset +0 
            repeat 2
    $ rom_health-=15
    u "[result] beats [selection], [playername]~"
    
    elif result == "scissors":
        u "HAHAHAHAHA!{nw}"
        play sound "UI_Quirky33.mp3"
        show ram scare:
            linear 0.090 xoffset -10 
            linear 0.090 xoffset +0 
            repeat 2
        $ram_health-=25
        u "[result] beats [selection], [playername]~"
I've tried everything I could think of but I'm still not sure what the program is asking for.
Last edited by Gushi on Sun May 20, 2018 11:31 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Expected Statement Error

#2 Post by Ocelot »

elif has no corresponding if statement:
https://i.imgur.com/FnMsGzb.png
I think, you intended those two lines to be executed only if result equal to "paper". To do so, make sure identation is consistent to other actions in if-block
< < insert Rick Cook quote here > >

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Expected Statement Error

#3 Post by kivik »

Your indentation is messed up: the two lines above your elif is at the same level as the original if block - that essentially ends your if block meaning the elif block isn't associated to the if block anymore.

Given that your code has quite a lot of duplication, you may be better off grouping the different statements together in your if block, and leave the rest out of the if block:

Code: Select all

    if result == "paper":
        $ rom_health-=15
        u "HAHAHAHA!{nw}"
    elif result == "scissors":
        $ram_health-=25
        u "HAHAHAHAHA!{nw}"

    play sound "UI_Quirky33.mp3"
    show rom scare:
        linear 0.090 xoffset -10 
        linear 0.090 xoffset +0 
        repeat 2
    u "[result] beats [selection], [playername]~"

Gushi
Newbie
Posts: 24
Joined: Sun Apr 01, 2018 3:25 pm
Projects: Project 4th Wall
itch: https://umberbridge.
Contact:

Re: Expected Statement Error

#4 Post by Gushi »

Ah its fixed, thank you.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]