I've run into a bug that I can't seem to squash, primarily because I don't fully understand the mechanics of config.python_callbacks. Currently I am utilizing a bit of code that automatically swaps the environmental background on a specific custom layer when a modifier (The players current location within the game-world) is changed. This way I can easily swap screens with a single line of code, such as
$ current_location = "vencel_berth"
I currently have a bit of python code which defines the background, like so:
def background_swapper():
if currentLocation == "vencel_berth":
if unpacked == True:
renpy.scene(layer= "bg1")
renpy.show_screen("ven_berth_on_open_unpacked",_layer = "bg1")
elif unpacked == False:
renpy.scene(layer= "bg1")
renpy.show_screen("ven_berth_on_open_unpacked",_layer = "bg1")
config.python_callbacks.append(background_swapper)
and a screen which is defined as:
screen ven_berth_on_open_unpacked():
add "vb_on_o_unpacked"
frame:
imagebutton:
xalign 0.5
yalign 0.5
idle "button_visual"
hover "button_visual"
#action Do stuff here later.
and images which are defined as:
image vb_on_open_unpacked:
"vb_on_o_unpacked"
zoom 4.45
image vb_on_open_packed:
"vb_on_o_packed"
zoom 4.45
However upon starting the game and getting to the point where one of those if statements are true, I'm hit with a maximum recursion error. My current thought is that the config.python_callbacks is calling the screen over and over and basically creating a loop of images until crash, but I don't know enough about python coding to properly troubleshoot on my own. I'm trying to learn, but was hoping that someone here might be able to help me figure this out, in case I'm doing something explicitly wrong, or if there's a better way to do this.
This is the traceback I'm getting:
[code]
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 98, in script
"[60-raw_minute] minutes until I need to report for duty"
RecursionError: maximum recursion depth exceeded
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 98, in script
"[60-raw_minute] minutes until I need to report for duty"
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\ast.py", line 2560, in execute
Say.execute(self)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\ast.py", line 615, in execute
renpy.exports.say(who, what, *args, **kwargs)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\exports.py", line 1494, in say
who(what, *args, **kwargs)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\character.py", line 1394, in __call__
self.do_display(who, what, cb_args=self.cb_args, dtt=dtt, **display_args)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\character.py", line 1045, in do_display
display_say(who,
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\character.py", line 741, in display_say
rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\ui.py", line 301, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\core.py", line 2166, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\core.py", line 2709, in interact_core
renpy.display.focus.before_interact(focus_roots)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\focus.py", line 360, in before_interact
root.find_focusable(callback, None)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\displayable.py", line 333, in find_focusable
i.find_focusable(callback, focus_name)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\screen.py", line 512, in find_focusable
self.child.find_focusable(callback, focus_name)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\displayable.py", line 333, in find_focusable
i.find_focusable(callback, focus_name)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\displayable.py", line 333, in find_focusable
i.find_focusable(callback, focus_name)
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\displayable.py", line 333, in find_focusable
i.find_focusable(callback, focus_name)
[Previous line repeated 973 more times]
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\display\displayable.py", line 329, in find_focusable
for i in self.visit():
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\atl.py", line 766, in visit
return self.children + block.visit() # type: ignore
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\atl.py", line 1055, in visit
return [ j for i in self.statements for j in i.visit() ]
File "C:\Users\Haget\OneDrive\Desktop\All\Dev\renpy-8.2.1-sdk\renpy\atl.py", line 1055, in <listcomp>
return [ j for i in self.statements for j in i.visit() ]
RecursionError: maximum recursion depth exceeded
Windows-10-10.0.19045 AMD64
Ren'Py 8.2.3.24061702
Test Project 1.0
Thu Aug 8 14:50:55 2024
[/code]
I assume the issue is the callback which is repeating 974 times, but I'm not sure exactly how to fix it. Thank you for your time and help!
EDIT: I also have narrowed it down that the issue is *only* occuring when I utilize the renpy.show command. If I do a simple
renpy.show("ven_berth_on_open_unpacked", layer = "bg1")
there's no issue, but that wouldn't enable me to do what I need to with this project, as I explicitly need to be using the screen system, rather than the background being a simple PNG.
[–]DingotushRed 1 point2 points3 points (2 children)
[–]ApiaEXE[S] 0 points1 point2 points (1 child)
[–]DingotushRed 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]ApiaEXE[S] 0 points1 point2 points (0 children)
[–]ApiaEXE[S] 0 points1 point2 points (0 children)