Page 1 of 1

NoneType object has no attribute 'append'

Posted: Thu Apr 11, 2019 8:13 pm
by ArizaLuca
I posted this in a previous topic but I finally managed to nail the problem down. In the topic viewtopic.php?f=51&t=47482, there is an aspect of it labeled 'append':

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<41):
                    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):
            func = renpy.curry(trans)(disp=self, m=m)
            return Transform(function=func)
        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.5
            return
    MouseParallax([(40,"farback"),(20,"back"),(-20,"front"),(-40,"inyourface")])
            
    def trans(d, st, at, disp=None, m=None):
        d.xoffset, d.yoffset = int(round(m*disp.xoffset)), int(round(m*disp.yoffset))
        return 0
I have a LayeredImage character whose file is here:
player definitions.rpy
(26.34 KiB) Downloaded 8 times
Their appearance is decided by a dress-up game, basically; that code is in the LayeredImage tutorial. If I do not display the character on the layered parallax, there is no issue; however when the character is on the 'front' layer, this error appears:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 195, in script
    p_thought "oh..."
AttributeError: 'NoneType' object has no attribute 'append'

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

Full traceback:
  File "game/script.rpy", line 195, in script
    p_thought "oh..."
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/ast.py", line 690, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/exports.py", line 1316, in say
    who(what, *args, **kwargs)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/character.py", line 1131, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/character.py", line 842, in do_display
    **display_args)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/character.py", line 591, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/ui.py", line 289, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 2687, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 3171, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/core.py", line 2083, in draw_screen
    renpy.config.screen_height,
  File "render.pyx", line 516, in renpy.display.render.render_screen
  File "render.pyx", line 244, in renpy.display.render.render
  File "/Users/arizaluca/Desktop/renpy-6.99.13-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 151, in renpy.display.render.render
  File "render.pyx", line 253, in renpy.display.render.render
AttributeError: 'NoneType' object has no attribute 'append'

Darwin-18.0.0-x86_64-i386-64bit
Ren'Py 7.2.0.424
Desruc Dolls 1.0
Thu Apr 11 20:11:33 2019
Does anyone know why this is? It's really not a problem otherwise; but this makes it problematic to display the character and the character image at the same time. Also, the game is currently configured to take the layered parallax code; and to make it so that it just isn't would take a longer time than i'd like.

Re: NoneType object has no attribute 'append'

Posted: Tue Apr 16, 2019 8:57 pm
by plaster
First, you're on 7.2.0. Update your Ren'Py! Maybe some of the patches will magically fix it :>

Second... "append" is just a built-in method for adding items to Python lists, so the issue isn't necessarily coming from appending items in MouseParallax. In fact, the traceback seems to be pointing to render.pyx, where it says

Code: Select all

rv.render_of.append(d)
. I'm kind of an idiot when it comes to coding but if I had to make an educated guess it looks like kill_cache is getting called when it shouldn't be, setting render_of to None instead of just an empty list.

Like PyTom said in your last thread, it would be easier to isolate the exact line(s) or scenario(s) causing the problem with a copy of the project or an example project set up the same way -- particularly it'd be helpful to see how your side image is implemented on screens and how your Character object is defined.

Re: NoneType object has no attribute 'append'

Posted: Fri May 03, 2019 8:49 am
by ArizaLuca

Code: Select all


layeredimage player:
    always:
        "player_base"
    if skin == 1:
        "player_skin_light"
    elif skin == 2:
        "player_skin_asian"
    elif skin == 3:
        "player_skin_tan"
    elif skin == 4:
        "player_skin_dark"
    if hair == 1:
        "player_hair_blonde"
    elif hair == 2:
        "player_hair_red"
    elif hair == 3:
        "player_hair_lightbrown"
    elif hair == 4:
        "player_hair_brown"
    elif hair == 5:
        "player_hair_darkbrown"
    elif hair == 6:
        "player_hair_black"
    if eye == 1:
        "blue eyes"
    elif eye == 2:
        "black eyes"
    elif eye == 3:
        "brown eyes"
    elif eye == 4:
        "gray eyes"
    elif eye == 5:
        "green eyes"
    elif eye == 6:
        "gold eyes"
    group eyebrows auto:
        attribute normal default
    group mouth auto:
        attribute frown default
    if pshadow:
        "player_shadow"
    if pshadow2:
        "player_shadow2"
    if ptears:
        "player_tears"
    if psweatdrop:
        "psweatdrop"
        
image side player = LayeredImageProxy("player", Transform(crop=(50, 0, 800, 750), zoom=0.6, xoffset=0))

## Eyes are defined as LiveComposites.

label start:
    
    show player onlayer front
    with dissolve
    
    p "..."
    
    show player angry onlayer front
    with dissolve
    
    p "..."
Has the effect of:
Screen Shot 2019-05-03 at 8.46.02 AM.png
then the error pops up:
Screen Shot 2019-05-03 at 8.46.08 AM.png
if you ignore, this comes up (it doesn't change emotion either despite being a layeredimageproxy):
Screen Shot 2019-05-03 at 8.46.13 AM.png
The thing is, I don't know WHERE in the code is the problem.