Suddenly, Saving means crashing!

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
marigoldsofthenight
Regular
Posts: 44
Joined: Sat Aug 14, 2010 5:31 pm
Contact:

Suddenly, Saving means crashing!

#1 Post by marigoldsofthenight » Mon Mar 10, 2014 11:06 am

Haven't had any kind of problems saving until recently when upgrading to the new version.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 163, in script
  File "renpy/common/00gamemenu.rpy", line 163, in python
  File "renpy/common/00action_file.rpy", line 259, in python
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed
Here's each of those lines in the script for possible further insight.

163 in gamemenu is '$ ui.interact()'. Here's the whole block of code starting at 161.

Code: Select all

    if renpy.has_screen(_game_menu_screen):
        $ renpy.show_screen(_game_menu_screen, *args, **kwargs)
        $ ui.interact()
        jump _noisy_return
and finally the actionfile code

Code: Select all

            renpy.save(fn, extra_info=save_name)
I'm stumped. Any ideas?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Suddenly, Saving means crashing!

#2 Post by xela » Mon Mar 10, 2014 12:05 pm

Code: Select all

config.use_cpickle = False
Add this to your init python and run the error again.

You have something in your code that cannot be pickled (no clue as to why it was working before now). Maybe a lambda or a nested function.
Like what we're doing? Support us at:
Image

marigoldsofthenight
Regular
Posts: 44
Joined: Sat Aug 14, 2010 5:31 pm
Contact:

Re: Suddenly, Saving means crashing!

#3 Post by marigoldsofthenight » Mon Mar 10, 2014 12:51 pm

xela wrote:

Code: Select all

config.use_cpickle = False
Add this to your init python and run the error again.

You have something in your code that cannot be pickled (no clue as to why it was working before now). Maybe a lambda or a nested function.
That didn't fix the issue, but it has helped me narrow down the problem! Thanks.

A while ago a user on here gave me coding advice to create a parallax effect in the game so that the scene background would move along with any mouse movement from the player. For some reason that code seems to be causing the issue, as I can finally avoid save-crashing when I remove it. Now the question is to figure out why it's causing the save crash, and how to fix whatever's causing the conflict.

Here's the code in question, if you (or anyone else, for that matter) has any ideas.

Code: Select all

init 800 python:
    class MouseParallax(renpy.Displayable):
        def __init__(self,layer_info):
            super(renpy.Displayable,self).__init__()
            self.xoffset,self.yoffset=0.0,0.0
            self.sort_layer=sorted(layer_info,reverse=True)
            cflayer=[]
            masteryet=False
            for m,n in self.sort_layer:
                if(not masteryet)and(m<0):
                    cflayer.append("master")
                    masteryet=True
                cflayer.append(n)
            if not masteryet:
                cflayer.append("master")
            cflayer.extend(["transient","screens","overlay"])
            config.layers=cflayer
            config.overlay_functions.append(self.overlay)
            return
        def render(self,width,height,st,at):
            return renpy.Render(width,height)
        def parallax(self,m):
            def trans(d,st,at):
                d.xoffset,d.yoffset=(int)(m*self.xoffset),(int)(m*self.yoffset)
                return 0
            return Transform(function=trans)
        def overlay(self):
            ui.add(self)
            for m,n in self.sort_layer:
                renpy.layer_at_list([self.parallax(m)],n)
            return
        def event(self,ev,x,y,st):
            import pygame
            if ev.type==pygame.MOUSEMOTION:
                self.xoffset,self.yoffset=((float)(x)/(config.screen_width))-0.5,((float)(y)/(config.screen_height))+0.0
            return
    MouseParallax([(400,"farback"),(200,"back"),(100,"front"),(-400,"inyourface")])

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Suddenly, Saving means crashing!

#4 Post by xela » Mon Mar 10, 2014 1:32 pm

marigoldsofthenight wrote:That didn't fix the issue
Would be a freaking miracle if it did... make sure to get rid of that line after the problem is gone or your game will take longer to save.

Code: Select all

            def trans(d,st,at):
                d.xoffset,d.yoffset=(int)(m*self.xoffset),(int)(m*self.yoffset)
                return 0
Here is your problem, move this function off the method namespace and it is solved.
Like what we're doing? Support us at:
Image

marigoldsofthenight
Regular
Posts: 44
Joined: Sat Aug 14, 2010 5:31 pm
Contact:

Re: Suddenly, Saving means crashing!

#5 Post by marigoldsofthenight » Mon Mar 10, 2014 3:54 pm

xela wrote:
marigoldsofthenight wrote:That didn't fix the issue
Would be a freaking miracle if it did... make sure to get rid of that line after the problem is gone or your game will take longer to save.

Code: Select all

            def trans(d,st,at):
                d.xoffset,d.yoffset=(int)(m*self.xoffset),(int)(m*self.yoffset)
                return 0
Here is your problem, move this function off the method namespace and it is solved.
Mind walking me through how to do that? Sorry. You're dealing with a novice, here. :oops:

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Suddenly, Saving means crashing!

#6 Post by xela » Mon Mar 10, 2014 4:36 pm

Walking through this might take a while... I wonder if trans can be applied to Transform if simply flipped into a method. Give me 5 mins.

Edit:
It's weird... I just set it up and saving works fine.
Like what we're doing? Support us at:
Image

marigoldsofthenight
Regular
Posts: 44
Joined: Sat Aug 14, 2010 5:31 pm
Contact:

Re: Suddenly, Saving means crashing!

#7 Post by marigoldsofthenight » Mon Mar 10, 2014 5:18 pm

xela wrote:Walking through this might take a while... I wonder if trans can be applied to Transform if simply flipped into a method. Give me 5 mins.

Edit:
It's weird... I just set it up and saving works fine.

Perhaps because you aren't actually running the feature, with the images?
I'm using the code provided by Elmiwisa in this thread:

http://lemmasoft.renai.us/forums/viewto ... =8&t=23438

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Suddenly, Saving means crashing!

#8 Post by xela » Mon Mar 10, 2014 5:30 pm

Yeah, I got it. Images are not required for this to crash, it's flawed from the moment transform is applied to the layers and it should not have saved in any version of Ren'Py I've ever worked with.

There is no way I can think of that would quickfix this. Problem is with that function but it's to intertwined with the rest of the class to simply place it on global namespace or even make some static method method out of it. I want to work on my project a bit tonight as well and this is not even remotely useful for it at the moment.

Is there any chance you can remove this from overlay and add it again on every save/load?
Like what we're doing? Support us at:
Image

marigoldsofthenight
Regular
Posts: 44
Joined: Sat Aug 14, 2010 5:31 pm
Contact:

Re: Suddenly, Saving means crashing!

#9 Post by marigoldsofthenight » Mon Mar 10, 2014 5:36 pm

xela wrote: Is there any chance you can remove this from overlay and add it again on every save/load?
Wouldn't even know where to begin, honestly. By all means, work on things that pertain to your project instead of mine. Maybe I'll contact the original creator of the code and ask them to troubleshoot.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Suddenly, Saving means crashing!

#10 Post by xela » Mon Mar 10, 2014 6:17 pm

Just removing it from overlay would not be enough either :(

If Elmiwisa is still around, he is without question the best person to rewrite this in the shortest amount of time.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]