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.
So I can't use lambda in Ren'Py, as it causes errors on save, is there any alternative? I've heard about renpy.curry(), but I didn't find it in docs to check how to use it, so are there any alternatives to 'sorting' dicts in Ren'Py?
Ocelot wrote: ↑Wed Apr 14, 2021 1:28 pm
Lambdas are just syntax sugar for normal functions. I always suggest to never use lambdas until you learn how they work.
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00keymap.rpy", line 463, in script
python hide:
File "renpy/common/00keymap.rpy", line 463, in <module>
python hide:
File "renpy/common/00keymap.rpy", line 482, in _execute_python_hide
renpy.save("_reload-1", "reload save game")
PicklingError: Can't pickle <type 'code'>: attribute lookup __builtin__.code failed
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "renpy/common/00keymap.rpy", line 463, in script
python hide:
File "C:\Users\Gamer\Desktop\Astral Lust\renpy-7.3.5-sdk/renpy/ast.py", line 922, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\Gamer\Desktop\Astral Lust\renpy-7.3.5-sdk/renpy/python.py", line 2218, in py_exec_bytecode
exec(bytecode, globals, locals)
File "renpy/common/00keymap.rpy", line 463, in <module>
python hide:
File "renpy/common/00keymap.rpy", line 482, in _execute_python_hide
renpy.save("_reload-1", "reload save game")
File "C:\Users\Gamer\Desktop\Astral Lust\renpy-7.3.5-sdk/renpy/loadsave.py", line 413, in save
reraise(t, e, tb)
File "C:\Users\Gamer\Desktop\Astral Lust\renpy-7.3.5-sdk/renpy/loadsave.py", line 399, in save
dump((roots, renpy.game.log), logf)
File "C:\Users\Gamer\Desktop\Astral Lust\renpy-7.3.5-sdk/renpy/loadsave.py", line 49, in dump
cPickle.dump(o, f, cPickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <type 'code'>: attribute lookup __builtin__.code failed
Windows-10-10.0.19041
Ren'Py 7.4.4.1439
Astral Lust 0.1.4b
Wed Apr 14 19:42:06 2021
Well, it appears that somewhere a function gets assigned to a variable which is then is saved. This is the main reason an error like that should appear. Sorted does not store key function, so it should not be the case.
Ocelot wrote: ↑Wed Apr 14, 2021 2:41 pm
Well, it appears that somewhere a function gets assigned to a variable which is then is saved. This is the main reason an error like that should appear. Sorted does not store key function, so it should not be the case.
I've solved the problem, code objects can't be pickled and I did it when deciding which buttons can appear, so I've removed compile() from code, and directly evaluated a string.