freeCodeCamp / LearnToCodeRPG

A visual novel video game where you learn to code and get a dev job 🎯
https://www.freecodecamp.org/news/learn-to-code-rpg-1-5-update/
BSD 3-Clause "New" or "Revised" License
1.06k stars 110 forks source link

Can't save the game after using the "back" Ren'Py feature [SOURCE OF THE ISSUE PROVIDED IN THE COMMENTS] #91

Closed Tiziano-Caruana closed 1 year ago

Tiziano-Caruana commented 1 year ago

What bug did you encounter?

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 170, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 170, in <module>
    $ ui.interact()
  File "renpy/common/00action_file.rpy", line 383, in __call__
    renpy.save(fn, extra_info=save_name)
TypeError: cannot pickle '_io.TextIOWrapper' object (perhaps store.requests = <module 'requests' from 'C:\\Users\\HOME\\Desktop\\LearnToCodeRPG-1.5-pc\\lib\\python3.9\\requests\\__init__.pyc'>)

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

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 170, in script
    $ ui.interact()
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\ast.py", line 1131, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\python.py", line 1061, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/00gamemenu.rpy", line 170, in <module>
    $ ui.interact()
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\core.py", line 3377, 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\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\core.py", line 4258, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1175, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\transition.py", line 53, in event
    return self.new_widget.event(ev, x, y, st) # E1101
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1175, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1175, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\screen.py", line 743, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1175, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1399, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 279, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1175, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1399, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 279, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 1175, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\layout.py", line 279, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\behavior.py", line 1073, in event
    return handle_click(self.clicked)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\behavior.py", line 1008, in handle_click
    rv = run(action)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\display\behavior.py", line 329, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 383, in __call__
    renpy.save(fn, extra_info=save_name)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\loadsave.py", line 408, in save
    reraise(t, e, tb)
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/site-packages/future/utils/__init__.py", line 441, in raise_
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\loadsave.py", line 389, in save
    dump((roots, renpy.game.log), logf)
  File "C:\Users\HOME\Desktop\LearnToCodeRPG-1.5-pc\renpy\compat\pickle.py", line 103, in dump
    pickle.dump(o, f, pickle.HIGHEST_PROTOCOL if highest else PROTOCOL)
TypeError: cannot pickle '_io.TextIOWrapper' object (perhaps store.requests = <module 'requests' from 'C:\\Users\\HOME\\Desktop\\LearnToCodeRPG-1.5-pc\\lib\\python3.9\\requests\\__init__.pyc'>)

Windows-10-10.0.22623 AMD64
Ren'Py 8.0.3.22090809
Learn to Code RPG 1.5
Sun Dec 25 11:52:54 2022

This error gets dumped when I try to save the game. It doesn't trigger a crash, and we can just rollback or ignore the error, but that means that progresses will not be saved

Steps to Reproduce

Use the "back" feature at least once and try to save the game

Screenshots

https://user-images.githubusercontent.com/78723550/209465502-9d4297e5-4743-4bd7-a0f7-aab1b60413c6.mp4

Additional Information

No response

Tiziano-Caruana commented 1 year ago

P.S. I tried to solve the issue by myself, without success. I'll attach the save_dump.txt here: save_dump.txt

Maybe line 626 can help to identify the problem: 1 roots['store.requests'] = <module 'requests' from 'C:\\Users\\HOME\\Desktop\\LearnToCodeRPG-1.5-pc\\lib\\python3.9\\requests\\__init__.pyc'>

Tiziano-Caruana commented 1 year ago

P.P.S. Found the problem!

The edit made to game/scripts/splashscreen.rpy in commit 458482ea93f908b7f6d6c307956881ba71f7581b is causing the crash. Performing a rollback of said edit fixes the problem, allowing the user to save the game

RuolinZheng08 commented 1 year ago

https://github.com/freeCodeCamp/LearnToCodeRPG/commit/c220e63c220cb5ca6b3169b1f771c8524d7d99c1