Weird exception; please help :S

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
herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

Weird exception; please help :S

#1 Post by herenvardo »

I've just written the first lines of my game for nanoreno and, when I tried to make the first test-run, I got a exception showing on my notepad:
I'm sorry, but an exception occured while executing your Ren'Py
script.

ParseError: On line 16 of game/script.rpy: expected statement.

g.screen_width = 800
^

While parsing game/script.rpy.

-- Full Traceback ------------------------------------------------------------

File "renpy\bootstrap.pyo", line 76, in bootstrap
File "renpy\main.pyo", line 218, in main
File "renpy\script.pyo", line 293, in load_script
File "renpy\script.pyo", line 94, in __init__
File "renpy\script.pyo", line 126, in load_file
File "renpy\parser.pyo", line 1233, in parse
File "renpy\parser.pyo", line 1209, in parse_block
File "renpy\parser.pyo", line 1155, in parse_statement
File "renpy\parser.pyo", line 1209, in parse_block
File "renpy\parser.pyo", line 1196, in parse_statement
File "renpy\parser.pyo", line 338, in error
ParseError: On line 16 of game/script.rpy: expected statement.

g.screen_width = 800
^

While parsing game/script.rpy.

Ren'Py Version: Ren'Py 5.4.2
I don't want to paste here the script: it's still short, but takes more than a hundred lines, so I've attached it. If you look at it, you might notice that there is not too much content yet, and it's based (copy-pasting required lines) on the example game's script. The case of the line which gives the error IS copy-pasted from the example, and it works in it; so I'm completely lost in why this exception occurs.
Does somebody know how to solve this error?

Thanks in advance.
Attachments
script.rpy
This is the script referenced by the error report.
(2.61 KiB) Downloaded 265 times
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#2 Post by PyTom »

Okay, it definitely has something to do with you using tabs instead of spaces to indent things. I haven't totally tracked down what, though.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#3 Post by PyTom »

Okay, I tracked down the error, and it was a bug in Ren'Py that caused tab characters to be improperly handled.

Seeing as how this bug has been around for a while, without anyone noticing (since at least 4.3 or so), I think the right solution is to forbid the use of the tab character entirely, as it has lead to problems with many languages.

So the resolution to this is that this will generate a more appropriate error message in 5.4.3, giving the line number on which the tab character was encountered.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

ShiraiJunichi
Miko-Class Veteran
Posts: 651
Joined: Sat May 21, 2005 12:28 pm
Location: University of Utah
Contact:

#4 Post by ShiraiJunichi »

but... I use the tab key all the time in SCITE, and things seem to work fine...

shaja
Regular
Posts: 73
Joined: Sun Oct 16, 2005 8:34 am
Contact:

#5 Post by shaja »

Another problem with the script (easily fixed) is that the string variable interpolations are missing the closing 's' for each.

So, should be:

Code: Select all

DM "In your case (%(char_gend)s/%(char_class)s), the race is %(char_race)s"

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

Thanks!!

#6 Post by herenvardo »

Wow! Just made a 'Replace all' taking tabs for 4-space sequences and it worked... well, not at all, I've still some errors but these are more 'normal' (ie: some text colors become almost invisible). The thing is that the code now runs so I can find & fix the 'normal' errors.
Thanks for your help.

When I inscribed for NaNoRenO, I got this reply:
ShiraiJunichi wrote:Welcome aboard. I hope we can see you during March as well- the forums are a great resource. Good luck!
Well, ShiraiJunichi has just proved right! I'd like to make the game without too much help, because it's an important personal challenge for me; but upon things like that of the tabs, I'd need a lot of imagination and luck to solve them by myself.
ShiraiJunichi wrote:but... I use the tab key all the time in SCITE, and things seem to work fine...
I don't know the editing software you use, but what I do know is that there are a lot of editors that insert an arbitrary amounts of spaces instead of tabs when you use the tab key. The editor I use, Notepad++, allows me to choose either to keep tabs or replace them by spaces, and also the amount of spaces to be used (tab size).
shaja wrote:Another problem with the script (easily fixed) is that the string variable interpolations are missing the closing 's' for each.

So, should be:

Code: Select all

DM "In your case (%(char_gend)s/%(char_class)s), the race is %(char_race)s"
Yes, just noticed it. I tried the tab replacement and got the corresponding exception at this point. I was wandering on reference before I saw your reply in order to solve it :?

And sure I'll make more mistakes as I go on, 'cos this is my first work with Ren'Py. Fortunately, I've wide experience in programming and it is a great help when debuging.
Last edited by herenvardo on Wed Mar 01, 2006 4:53 pm, edited 1 time in total.
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#7 Post by PyTom »

That's because SciTE (like most sane editors) subsitutes an appropriate number of spaces for each tab.

Good catch shaja.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: bonnie_641