My "Game" don't work please help File "game/script-example.rpy", line 341: indentation mismatch.

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
slenderman64
Newbie
Posts: 9
Joined: Tue Feb 27, 2018 6:21 am
Contact:

My "Game" don't work please help File "game/script-example.rpy", line 341: indentation mismatch.

#1 Post by slenderman64 »

:D Hello, I'm a beginner in renPy and i write this code but it not works :x

Code: Select all

label a:
     python:
import random
rndm = random.randint(1,200)
label nbrplace:
nbr = renpy.input("Nombre de 0 a 200", length=3)

if nbr == rndm
usay "Bravo [player], tu as gagné!"
scene white
return
else

if nbr < rndm
usay "inférieur!"
jump nbrplace

else
usay "supérieur"
jump nbrplace
The error is:

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


File "game/script-example.rpy", line 341: indentation mismatch.

Ren'Py Version: Ren'Py 6.99.14.1.3218
Tue Feb 27 11:14:41 2018

the error at line 341 is : label a:



Sorry, I'm not English so I do not write very well

mikolajspy
Regular
Posts: 169
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Too many, check signature
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Re: My "Game" don't work please help File "game/script-example.rpy", line 341: indentation mismatch.

#2 Post by mikolajspy »

Indentation is about spaces/tabulator, you can take a look at documentation here - https://www.renpy.org/doc/html/language ... and-blocks
Also, I think it's better to put python before any labels if it's needed. There is also random build in renpy. The difference is that the build-in remembers what it chooses on rollback.
And you need to add ':' after if or else.
So your code should look more or less like this. I don't know if it's correct though and if it will work.

Code: Select all

default rndm = 0  # define variables
default nbr = 0

label a:
    $ rndm = renpy.random.randint(1,200) # assign random number, I guess you don't want it to be changed when player guesses wrong, so another label is fine.
label nbrplace:
    $ nbr = renpy.input("Nombre de 0 a 200", length=3)
    if nbr == rndm:
        usay "Bravo [player], tu as gagné!"
        scene white
        return
    else:
        if nbr < rndm:
        usay "inférieur!"
        jump nbrplace
        else:
        usay "supérieur"
        jump nbrplace

User avatar
Draziya
Regular
Posts: 70
Joined: Sun Nov 26, 2017 8:50 am
Completed: this was for you. [NaNoRenO 19], Acetylene [AceJam19], Ah!! My Roommate is a Succubus Hellbent on World [MonJam 18], I Don't Have A Clue [QRMJam 18], Cautionary Tale [NaNoRenO 18], OP Dodge Cross [GGJ 18], Acetone [AceJam 18]
Projects: I'm a love interest in my childhood friend's reverse harem!!
Organization: Watercress
itch: Drazillion
Contact:

Re: My "Game" don't work please help File "game/script-example.rpy", line 341: indentation mismatch.

#3 Post by Draziya »

Everything I was going to say was answered before me! But I might as well point out one problem in your code.

Code: Select all

$ nbr = renpy.input("Nombre de 0 a 200", length=3)
Should be

Code: Select all

$ nbr = int(renpy.input("Nombre de 0 a 200", length=3))
Or else Renpy tries to compare a string to rndm, not an integer like you want it to.
Image

slenderman64
Newbie
Posts: 9
Joined: Tue Feb 27, 2018 6:21 am
Contact:

Re: My "Game" don't work please help File "game/script-example.rpy", line 341: indentation mismatch.

#4 Post by slenderman64 »

Now, i have this error:
File "game/script-example.rpy", line 354: indentation mismatch.

Code: Select all

python:
default rndm = 0  # define variables
default nbr = 0

label a:
     rndm = renpy.random.randint(1,200) # assign random number, I guess you don't want it to be changed when player guesses wrong, so another label is fine.
label nbrplace:
$ nbr = int(renpy.input("Nombre de 0 a 200", length=3))    
     if nbr == rndm:
        usay "Bravo [player], tu as gagné!"
        scene white
       
    
    else:
        if nbr < rndm:
        usay "inférieur!"
        jump nbrplace
        else:
        usay "supérieur"
        jump nbrplace
        


line 354 is :

Code: Select all

---> else:
        if nbr < rndm:
        usay "inférieur!"
        jump nbrplace
        else:
        usay "supérieur"
        jump nbrplace

User avatar
Draziya
Regular
Posts: 70
Joined: Sun Nov 26, 2017 8:50 am
Completed: this was for you. [NaNoRenO 19], Acetylene [AceJam19], Ah!! My Roommate is a Succubus Hellbent on World [MonJam 18], I Don't Have A Clue [QRMJam 18], Cautionary Tale [NaNoRenO 18], OP Dodge Cross [GGJ 18], Acetone [AceJam 18]
Projects: I'm a love interest in my childhood friend's reverse harem!!
Organization: Watercress
itch: Drazillion
Contact:

Re: My "Game" don't work please help File "game/script-example.rpy", line 341: indentation mismatch.

#5 Post by Draziya »

If you look closely, the indents of the if and the else don't quite match up. The else is a liitle bit too much to the left.

Also you haven't indented the if statements after the else.

Code: Select all

label nbrplace:
    $ nbr = int(renpy.input("Nombre de 0 a 200", length=3))    
    if nbr == rndm:
        usay "Bravo [player], tu as gagné!"
        scene white
       
    
    else:
        if nbr < rndm:
            usay "inférieur!"
            jump nbrplace
        else:
            usay "supérieur"
            jump nbrplace
Image


Post Reply

Who is online

Users browsing this forum: No registered users