Beginner seeking guidance

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
Kikered

Beginner seeking guidance

#1 Post by Kikered »

Greetings. I've been trying to experiment with Ren'Py 4.7 for the past day to get a better feel for it. Basically, the code that I have for this small script seems sound, but run_game.exe comes up with an error of some sort when it tries to compile the code. The code is reproduced below:

Code: Select all

init:
	image bedroom = Image("bedroom.jpg")
	
label start:
	scene bedroom

	"There's nothing here. How sad."

	$ renpy.full_restart()
The script is properly saved as an .rpy file, and the bedroom image is in the same folder as the script. The "run_(folder name)" executable also matches with the folder with the previously mentioned items.

Thanks in advance.

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 »

I don't see anything obviously wrong with this. Could you post the error message Ren'Py provides, so that I can use it to figure out what the engine thinks is going wrong?

RedSlash
Veteran
Posts: 351
Joined: Sun Oct 31, 2004 12:48 am
Location: Canada
Contact:

#3 Post by RedSlash »

Last time I had a similar problem with perfectly correct code and crashing (v4.1) was the fact that renpy was extremely sensitive with tab/space characters for indendation. I think what happened was that it wouldn't work if I used spaces instead of tabs for indentation. I'm am not sure if this is still the case but you can check.

Kikered

#4 Post by Kikered »

Sure thing:
I'm sorry, but an exception occured while executing your Ren'Py
script.

LookupError: unknown encoding: unicode_escape

While loading the script.

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

File "run_game.py", line 60, in main
File "renpy\main.pyc", line 149, in main
File "renpy\script.pyc", line 189, in load_script
File "renpy\script.pyc", line 83, in __init__
File "renpy\script.pyc", line 109, in load_file
File "renpy\parser.pyc", line 1188, in parse
File "renpy\parser.pyc", line 145, in list_logical_lines
File "renpy\parser.pyc", line 23, in __init__
LookupError: unknown encoding: unicode_escape

While loading the script.

Ren'Py Version: Ren'Py 4.7

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:

#5 Post by PyTom »

Okay, this is caused by the composition of two problems, one of them yours and one of them mine.

The problem you're having is that you didn't end the file in a newline. Add a couple blank lines to the end of the file, and you'll be fine.

My problem is that I forgot to include an encoding with the exe, which means that you don't see the right error message for that problem. I might cut a 4.7.1 tomorrow fixing this problem, and adding a few new features intended to help the NaNoRenO participants.

Kikered
Regular
Posts: 128
Joined: Sat Feb 26, 2005 3:02 pm
Completed: Quine, The Secret Ingredient
Projects: Metropolitan Blues, Mirai Imouto, Temple Glen, Fuyu no Tabi, MIA
Organization: Team BG
Location: The Midwest
Contact:

#6 Post by Kikered »

Well, adding the newlines didn't fix the problem. Is there a specific number that I need to add? Or perhaps I need to use an escape character instead?

Here's the new error received after adding the newlines:
I'm sorry, but an exception occured while executing your Ren'Py
script.

LookupError: unknown encoding: unicode_escape

While loading the script.

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

File "run_game.py", line 60, in main
File "renpy\main.pyc", line 149, in main
File "renpy\script.pyc", line 189, in load_script
File "renpy\script.pyc", line 83, in __init__
File "renpy\script.pyc", line 109, in load_file
File "renpy\parser.pyc", line 1193, in parse
File "renpy\parser.pyc", line 1171, in parse_block
File "renpy\parser.pyc", line 1117, in parse_statement
File "renpy\parser.pyc", line 1171, in parse_block
File "renpy\parser.pyc", line 1158, in parse_statement
File "renpy\parser.pyc", line 338, in error
File "renpy\parser.pyc", line 23, in __init__
LookupError: unknown encoding: unicode_escape

While loading the script.

Ren'Py Version: Ren'Py 4.7
Sorry for being a nuisance. :oops:

User avatar
rioka
Royal Manga Tutor
Posts: 1255
Joined: Fri Jul 16, 2004 12:21 pm
Completed: Amgine Park, Garden Society: Kykuit, Metropolitan Blues (art)
Location: somewhere in NY
Contact:

#7 Post by rioka »

Oh man, this error fills me up with annoyance and ire just by looking at it... (I had the same problem when I started out... )

Mine was particular about all the lines being exactly four spaces. (Seriously, at one point, I put in five spaces instead of four and it all got snippy at me.) Yours look to be about only three spaces. I suggest you play around with the spacing.

Megaman Z
Miko-Class Veteran
Posts: 829
Joined: Sun Feb 20, 2005 8:45 pm
Projects: NaNoRenO 2016, Ren'Py tutorial series
Location: USA
Contact:

#8 Post by Megaman Z »

(comes back from experimenting with the sample script)
It's the indenting... it has to be four spaces unless...
A) it's a label. no indentation
B) it's the init block(s) (no indentation for the label, indent 4 spaces afterwards), or
C) you have a branch located in some previous line(s) of "code" (triggered by variable checking or a menu/decision), in which you add another four spaces to the indent unless you are ending the branch. (correct me if I'm wrong here, but would a branch within another branch have a 4+4+4=12 space indent?)
~Kitsune Zeta

Kikered
Regular
Posts: 128
Joined: Sat Feb 26, 2005 3:02 pm
Completed: Quine, The Secret Ingredient
Projects: Metropolitan Blues, Mirai Imouto, Temple Glen, Fuyu no Tabi, MIA
Organization: Team BG
Location: The Midwest
Contact:

#9 Post by Kikered »

Haha! Thanks for the help, everyone. I've been using tabs to indent the code since 1) it was more convenient than using spaces and 2) it was the convention for indenting code in C++ and Java. Apparently, it failed. Perhaps this could be something that the next version could implement. :wink:

Thanks again.

RedSlash
Veteran
Posts: 351
Joined: Sun Oct 31, 2004 12:48 am
Location: Canada
Contact:

#10 Post by RedSlash »

Hmm.. that explains my tab/spacing problem. My editor had tab spacing set to 3, so it failed.
I've been using tabs to indent the code
Make sure your editor doesn't automatically convert your tabs to spaces too.

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:

#11 Post by PyTom »

Actually, the code does convert tabs to spaces. It assumes an 8-space tab when it does so, so if you have tabs set to something other that 8 spaces, that could definitely cause a problem like this.

(Of course, it doesn't help that the error report is being masked. I'll fix that shortly.)

In general, it's poor programming form to mix tabs and spaces in the same file, especially with indentation-sensitive languages like Python and Ren'Py.

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:

#12 Post by PyTom »

Ren'Py 4.7.1 is up at:

http://www.bishoujo.us/renpy/dl/4.7.1/renpy-4.7.1.zip

It fixes bugs with reporting parse error messages. I'll post a release note tomorrow.

Post Reply

Who is online

Users browsing this forum: CalixtheGreat, henne