[Help] Python block expects a non-empty block.

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
Spazzlez
Newbie
Posts: 9
Joined: Tue Feb 13, 2018 3:36 pm
Tumblr: goldieblues
Deviantart: Goldie Blues
Contact:

[Help] Python block expects a non-empty block.

#1 Post by Spazzlez »

Hello! I am Spazzlez, and I am currently working on a game.

As of right now, I am currently working on allowing the player to name themselves, while also adding an option that will give them a default name.

Code: Select all

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


File "game/script.rpy", line 145: python block expects a non-empty block.
    python:
           ^

File "game/script.rpy", line 147: expected statement.
    povFirstName,povLastName = povName.split(" ")
                ^

Ren'Py Version: Ren'Py 6.99.13.2919
This is what the engine tells me what is currently giving me an issue. If someone could help me, I would very musch appreciate it!

Spazzlez
Newbie
Posts: 9
Joined: Tue Feb 13, 2018 3:36 pm
Tumblr: goldieblues
Deviantart: Goldie Blues
Contact:

Re: [Help] Python block expects a non-empty block.

#2 Post by Spazzlez »

I would also like to show you a part of the code, if it helps.

Code: Select all

label nameinput:
define pov = Character("[povName]", color = "#80CE44")

$ povName = renpy.input("Please sign your name.", length=50) or "Tyler Rice"
python:
if " " in povName:  #checks there is space char in name, indicating a full name.
    povFirstName,povLastName = povName.split(" ")
if " " in povName:
    pov "My name is [povFirstName], last name is [povLastName]. Together, it is [povName]."
else:
    pov "My name is [povName]."
    
jump comply

label basicname:
python:
    define pov = Character("[povName]", color = "#80CE44")
python:[povName] = "Tyler Rice"
    if " " in povName:
        povFirstName,povLastName = povName.split(" ")
    
jump lashout

User avatar
Lord Hisu
Regular
Posts: 58
Joined: Sun Feb 11, 2018 2:31 am
Contact:

Re: [Help] Python block expects a non-empty block.

#3 Post by Lord Hisu »

You need to indent your code correctly. Every time you create a block you should indent the code.
That means every time you use (:) and press enter, you are creating a block, and everything inside that block should be 4 spaces to the right.

Code: Select all

    define pov = Character("[povName]", color = "#80CE44")
    python:
        povName = renpy.input("Please sign your name.", length=50, default="Tyler Rice")
        if " " in povName:  #checks there is space char in name, indicating a full name.
            povFirstName,povLastName = povName.split(" ")
    if " " in povName:
        pov "My name is [povFirstName], last name is [povLastName]. Together, it is [povName]."
    else:
        pov "My name is [povName]."
I believe this piece of code will do what you want.

EDIT:
Inputting 3 or more names will break your code.

Spazzlez
Newbie
Posts: 9
Joined: Tue Feb 13, 2018 3:36 pm
Tumblr: goldieblues
Deviantart: Goldie Blues
Contact:

Re: [Help] Python block expects a non-empty block.

#4 Post by Spazzlez »

Thank you for the help! I appreciate it very much!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Nozori_Games, voluorem