Page 1 of 1

Problem saving after using im.load_surface

Posted: Fri Apr 24, 2020 7:17 am
by sapiboonggames
Hello there. I encountered a saving error when I tried using "im.load_surface" function.

The code itself:

Code: Select all

$ floor=im.load_surface("map/beach_colormap.png")
The traceback error occurred whenever I tried to save the game:

Code: Select all

While running game code:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "renpy/common/00action_file.rpy", line 372, in __call__
    renpy.save(fn, extra_info=save_name)
TypeError: no default __reduce__ due to non-trivial __cinit__ (perhaps store.floor = <Surface(1920x1081x32)>)
Full traceback:

Code: Select all

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\ast.py", line 914, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\python.py", line 2028, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "C:\Users\felin\Desktop\Renpy program\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\felin\Desktop\Renpy program\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\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\core.py", line 3518, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\screen.py", line 714, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\behavior.py", line 962, in event
    return handle_click(self.clicked)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\behavior.py", line 897, in handle_click
    rv = run(action)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\behavior.py", line 313, in run
    new_rv = run(i, *args, **kwargs)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\display\behavior.py", line 320, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 372, in __call__
    renpy.save(fn, extra_info=save_name)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\loadsave.py", line 422, in save
    six.reraise(t, e, tb)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\loadsave.py", line 405, in save
    dump((roots, renpy.game.log), logf)
  File "C:\Users\felin\Desktop\Renpy program\renpy-7.3.5-sdk\renpy\loadsave.py", line 51, in dump
    pickle.dump(o, f, pickle.HIGHEST_PROTOCOL)
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 1370, in dump
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 224, in dump
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 548, in save_tuple
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 306, in save
  File "stringsource", line 2, in pygame_sdl2.surface.Surface.__reduce_cython__
TypeError: no default __reduce__ due to non-trivial __cinit__ (perhaps store.floor = <Surface(1920x1081x32)>)

Even if the "floor" variable has been set to another value, it still causes an error (in log). The traceback:

Code: Select all

While running game code:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "renpy/common/00action_file.rpy", line 372, in __call__
    renpy.save(fn, extra_info=save_name)
TypeError: no default __reduce__ due to non-trivial __cinit__ (perhaps renpy.game.log.log[113].stores['store']['floor'] = <Surface(1920x1081x32)>)
Any help is appreciated!

Re: Problem saving after using im.load_surface

Posted: Fri Apr 24, 2020 1:46 pm
by Per K Grok
sapiboonggames wrote: Fri Apr 24, 2020 7:17 am Hello there. I encountered a saving error when I tried using "im.load_surface" function.

------

Any help is appreciated!

OK. So I see you have been using my colormap code.

I was surprised to see this problem. I has been using this code in my wip game for months. Surely I must have made a save or two earlier.

Apparently not for when I tried to make a save I got the same problem.

But I have used im.load_surface in earlier games that has been able to be saved, So why not this game.

Going back to an earlier game I noticed that I had used im.load_surface inside a function, which meant that on a save there was no loaded surface to save. That was a difference.

So I tried that out. This is the function

Code: Select all

init python:
    def colorpick(pix,x,y):
        if pix==1:
            floor=im.load_surface("images/bg/skullroom_map.png")
        inout=floor.get_at((x,y)) [:3]
        return inout
The pix variable makes it possible to have more than on colormap that are used at different times. Here there is only one.


In the code we remove

#$ floor=im.load_surface("images/bg/skullroom_map.png")

and we change
#$ inout=floor.get_at((SemX,SemY)) [:3]
to
$ inout=colorpick(1,SemX,SemY)

(or whatever x, y value you are using)

I tried it out and it worked. The code does it's work and the scene could be saved and then loaded.

Just tested it the one time but I think that was what was needed.
----

Sorry I did not catch this earlier. I never figured that could be a problem.

Thank you for bringing it to my attention.

Re: Problem saving after using im.load_surface

Posted: Fri Apr 24, 2020 2:40 pm
by sapiboonggames
Thank you very much for the help!