[solved] Coding snafu?

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
User avatar
The King
Regular
Posts: 35
Joined: Fri Sep 25, 2020 12:37 pm
Completed: 0
Projects: LB
Contact:

[solved] Coding snafu?

#1 Post by The King » Fri Sep 25, 2020 12:45 pm

I'm new to renpy coding, and while I was testing the game, I got a traceback that I have no idea what it means. You can see it below.

I'm sorry, but an uncaught exception occurred.

After initialization, but before game start.
File "game/screens.rpy", line 619, in prepare_screen
screen file_slots(title):
File "game/screens.rpy", line 619, in prepare
screen file_slots(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "renpy/common/00action_file.rpy", line 566, in __init__
self.page = str(page)
File "game/screens.rpy", line 619, in prepare_screen
screen file_slots(title):
File "game/screens.rpy", line 619, in prepare
screen file_slots(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "renpy/common/00action_file.rpy", line 566, in __init__
self.page = str(page)
Exception: Cannot start an interaction in the middle of an interaction, without creating a new context.

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

Full traceback:
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\bootstrap.py", line 316, in bootstrap
renpy.main.main()
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\main.py", line 578, in main
run(restart)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\main.py", line 94, in run
renpy.display.screen.prepare_screens()
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\display\screen.py", line 931, in prepare_screens
s.ast.prepare_screen()
File "game/screens.rpy", line 619, in prepare_screen
screen file_slots(title):
File "game/screens.rpy", line 619, in prepare
screen file_slots(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\python.py", line 2052, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "<screen language>", line 683, in <module>
File "renpy/common/00action_file.rpy", line 566, in __init__
self.page = str(page)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\character.py", line 1142, in __call__
self.do_display(who, what, cb_args=self.cb_args, **display_args)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\character.py", line 842, in do_display
**display_args)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\character.py", line 591, in display_say
rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\ui.py", line 297, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\display\core.py", line 2702, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\display\core.py", line 2879, in interact_core
renpy.display.screen.prepare_screens()
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\display\screen.py", line 931, in prepare_screens
s.ast.prepare_screen()
File "game/screens.rpy", line 619, in prepare_screen
screen file_slots(title):
File "game/screens.rpy", line 619, in prepare
screen file_slots(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 623, in prepare
use game_menu(title):
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 625, in prepare
fixed:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 672, in prepare
hbox:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 682, in prepare
if config.has_autosave:
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "game/screens.rpy", line 683, in prepare
textbutton _("{#auto_page}A") action FilePage("auto")
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\python.py", line 2052, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "<screen language>", line 683, in <module>
File "renpy/common/00action_file.rpy", line 566, in __init__
self.page = str(page)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\character.py", line 1142, in __call__
self.do_display(who, what, cb_args=self.cb_args, **display_args)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\character.py", line 842, in do_display
**display_args)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\character.py", line 591, in display_say
rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\ui.py", line 297, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\King\Downloads\renpy-7.3.5-sdk\renpy\display\core.py", line 2680, in interact
raise Exception("Cannot start an interaction in the middle of an interaction, without creating a new context.")
Exception: Cannot start an interaction in the middle of an interaction, without creating a new context.

Windows-8-6.2.9200
Ren'Py 7.3.5.606
Codename X 0.1.0 demo
Thu Sep 24 21:03:21 2020

My question is, what does any of this mean? I'm not sure what I did to get this to show up. My only hypothesis is that I wrote too much total script. I divided my script into several files, but that never caused a problem, so I'm wondering if I wrote too much in each script. That can't be it though, right? I'm confused and I want to know how I can fix this, because I can't test my game. Whenever I click the launch project option, this is what shows up now. Can somebody help me fix this? Thank you. :)
Last edited by The King on Mon Oct 05, 2020 11:31 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Coding snafu?

#2 Post by Alex » Fri Sep 25, 2020 5:02 pm

Check the changes you've made in screens.rpy (lines about 619-682) if you've made any.

The other thing to check is if you've named any of your variables, functions, characters the name from this list - https://www.renpy.org/doc/html/reserved.html
If it is so, try to rename your variable/function/character.

User avatar
The King
Regular
Posts: 35
Joined: Fri Sep 25, 2020 12:37 pm
Completed: 0
Projects: LB
Contact:

Re: Coding snafu?

#3 Post by The King » Fri Sep 25, 2020 11:09 pm

I don't think this part is any different than the default, but I'm not sure.

screen file_slots(title):

default page_name_value = FilePageNameInputValue(pattern=_("Page {}"), auto=_("Automatic saves"), quick=_("Quick saves"))

use game_menu(title):

fixed:

## This ensures the input will get the enter event before any of the
## buttons do.
order_reverse True

## The page name, which can be edited by clicking on a button.
button:
style "page_label"

key_events True
xalign 0.5
action page_name_value.Toggle()

input:
style "page_label_text"
value page_name_value

## The grid of file slots.
grid gui.file_slot_cols gui.file_slot_rows:
style_prefix "slot"

xalign 0.5
yalign 0.5

spacing gui.slot_spacing

for i in range(gui.file_slot_cols * gui.file_slot_rows):

$ slot = i + 1

button:
action FileAction(slot)

has vbox

add FileScreenshot(slot) xalign 0.5

text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
style "slot_time_text"

text FileSaveName(slot):
style "slot_name_text"

key "save_delete" action FileDelete(slot)

## Buttons to access other pages.
hbox:
style_prefix "page"

xalign 0.5
yalign 1.0

spacing gui.page_spacing

textbutton _("<") action FilePagePrevious()

if config.has_autosave:
textbutton _("{#auto_page}A") action FilePage("auto")

if config.has_quicksave:
textbutton _("{#quick_page}Q") action FilePage("quick")

## range(1, 10) gives the numbers from 1 to 9.
for page in range(1, 10):
textbutton "[page]" action FilePage(page)

textbutton _(">") action FilePageNext()

Am I just blind or something? I can't see any difference between what I'd get from creating a new project. Is it the automatic and quick save feature that's messing things up? If so, does this whole part relate to just the automatic and quick save feature? If so, then would deleting it fix this? Sorry if I'm bothering you, I'm just really confused and need help.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Coding snafu?

#4 Post by Per K Grok » Sat Sep 26, 2020 4:51 am

The King wrote:
Fri Sep 25, 2020 11:09 pm
I don't think this part is any different than the default, but I'm not sure.

------

Am I just blind or something? I can't see any difference between what I'd get from creating a new project. Is it the automatic and quick save feature that's messing things up? If so, does this whole part relate to just the automatic and quick save feature? If so, then would deleting it fix this? Sorry if I'm bothering you, I'm just really confused and need help.
I don't see anything wrong in that code (I can't see the indentation, but if that was wrong I think the error message would have been different)

Sometimes the actual error is somewhere else compared to what is listed in the error message.

Do you remember what the last things you did between the game working and not working was? That's likely to be the place where your problem has it's origin.

User avatar
The King
Regular
Posts: 35
Joined: Fri Sep 25, 2020 12:37 pm
Completed: 0
Projects: LB
Contact:

Re: Coding snafu?

#5 Post by The King » Sat Sep 26, 2020 5:24 pm

The error only started showing up after I added new content in my script files. I have an older backup, which works fine until I write more to the script. I have the script split into several files, a prologue and 9 chapters, as well as special endings and a collection of scenes I haven't found a place in the story for yet. It seems like no matter what script I add more to, it always results in the same message. That's really the only thing I can think of that caused it. I have changed very little about the other files so I'm not sure where I went wrong. Could the scripts be the problem? Do I have to re-write them all?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Coding snafu?

#6 Post by Per K Grok » Sun Sep 27, 2020 1:59 am

The King wrote:
Sat Sep 26, 2020 5:24 pm
The error only started showing up after I added new content in my script files. I have an older backup, which works fine until I write more to the script. I have the script split into several files, a prologue and 9 chapters, as well as special endings and a collection of scenes I haven't found a place in the story for yet. It seems like no matter what script I add more to, it always results in the same message. That's really the only thing I can think of that caused it. I have changed very little about the other files so I'm not sure where I went wrong. Could the scripts be the problem? Do I have to re-write them all?

So you have a backup that works. That's great. That will probably save you a lot of work.

You have your script divided up in a number of files. That should not be a problem. I would expect that to be a common practices.

One or many rpy-files does not matter for the computer. Splitting the code up in different files is just for the coder to have easier control over where different parts of the code is, at least as far as I can understand.

Some pieces of code need to be run before other pieces of code. gui.rpy and screens.rpy have "init offset" at the start of the code to make that code run before other code. Other than that it should not matter to the computer in which file you put your code.

I suspect that there is some problem with a piece of code you want to add and that your first step should be to identify that code.

I would suggest that you first try with adding some code that should not have any problem in itself, such as a couple of lines of dialog. This to test that it is not the numbers of lines that is the problem. It seems really unlikely that it could be, but it should be easy to run that test and get that question out of the way.

If that turns out OK next step would be to add the new code you actually want to add, one step at the time, testing to run the game between each step and see when it breaks the game.

User avatar
The King
Regular
Posts: 35
Joined: Fri Sep 25, 2020 12:37 pm
Completed: 0
Projects: LB
Contact:

Re: Coding snafu?

#7 Post by The King » Sun Sep 27, 2020 9:14 pm

Okay, I think I may have found the problem. It seems the problem was that I did this:

define str = Character('Stranger', color="#000000")

Does str mean something? It seems like it's not a number of characters issue as far as I can see, it's just this one that causes problems. Fortunately I don't really need a "Stranger" character, so that should be okay. Thank you for helping me out and giving me advice, and sorry if I wasted your time. I think this should be it for now. Take care. :)

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Coding snafu?

#8 Post by Imperf3kt » Mon Sep 28, 2020 1:28 am

In python, str stands for string and is a function used to convert an integer into a string.
https://www.w3schools.com/python/ref_func_str.asp

Its also on the reserved names index for this reason.
https://www.renpy.org/doc/html/reserved.html
Changing it to anything other than "str" will work. (with the exception anything else on the reserved names list)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

Post Reply

Who is online

Users browsing this forum: No registered users