Problem saving after using im.load_surface

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
sapiboonggames
Veteran
Posts: 299
Joined: Thu Jan 05, 2012 8:53 am
Completed: I Love You, Brother [BxB]
Contact:

Problem saving after using im.load_surface

#1 Post by sapiboonggames » Fri Apr 24, 2020 7:17 am

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!
Visit my website: http://www.sapiboong.com

User avatar
Per K Grok
Miko-Class Veteran
Posts: 774
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 & 2
Projects: the Phantom Flier
itch: per-k-grok
Location: Sverige
Contact:

Re: Problem saving after using im.load_surface

#2 Post by Per K Grok » Fri Apr 24, 2020 1:46 pm

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.

User avatar
sapiboonggames
Veteran
Posts: 299
Joined: Thu Jan 05, 2012 8:53 am
Completed: I Love You, Brother [BxB]
Contact:

Re: Problem saving after using im.load_surface

#3 Post by sapiboonggames » Fri Apr 24, 2020 2:40 pm

Thank you very much for the help!
Visit my website: http://www.sapiboong.com

Post Reply

Who is online

Users browsing this forum: No registered users