error with self:remove?

22 views
Skip to first unread message

brwiz

unread,
Dec 10, 2012, 2:01:51 AM12/10/12
to libzo...@googlegroups.com
i was coding this strange game i'm working on, when suddenly i get an equally strange error regarding the remove function! it says the value is null, as displayed here...

my code:

DEBUG = true
STRICT = true
require 'zoetrope'

Frogface = Animation:extend{
    width = 100,
    height = 100,
    image = 'assets/froganimation.png',

    sequences =
    {
        talk = { frames = {1, 2}, fps = 10 }
    },

    onUpdate = function(self)
        self:play('talk')
    end
}

Dialog = Text:extend{
    
    dialog = 0,
    font = 14,
    width = 300,
    height = 20,

    onUpdate = function (self)

        if self.dialog == 0 then
            self.tint = {0,0,0}
            self.text = 'there is a disturbance in the solar system. the mystery of the season.'
        end
        if self.dialog == 1 then
            self.tint = {0,0,0}
            self.text = 'the mystery of the season the mystery of the season the mystery of the season.'
        end
        if self.dialog == 2 then
            self.tint = {0,0,0}
            self.text = 'today the mystery will land.'
        end
        if self.dialog == 3 then
            self.tint = {0,0,0}
            self.text = 'be of care..............'
        end

        if the.keys:justPressed(' ') then
            self.dialog = self.dialog + 1
            if self.dialog == 3 then
                self:remove(the.app.frogface)
            end
        end

    end

}

DialogBox = Tile:extend{
    
    width = 742,
    height = 160,
    image = 'assets/dialogbox.png'

}

the.app = App:new{

    onRun = function(self)
        self:add(Fill:extend {width = 800, height = 600, fill = {255,255,255} } )
        self.dialogbox = DialogBox:new{x = 24, y = 424}
        self:add(self.dialogbox)
        self.frogface = Frogface:new{x = 56, y = 456}
        self:add(self.frogface)
        self.dialog = Dialog:new{x = 176, y = 456}
        self:add(self.dialog)
    end

}

if anyone could help me out, that would be great! i know i've already asked for help once today, but i'm really interested in this engine and want to code in it! if anyone can think up any solutions, that would be great!


Berzee

unread,
Dec 10, 2012, 8:52:38 AM12/10/12
to libzo...@googlegroups.com
Looks like, because you are in the onUpdate method of Dialog, "self" is actually referring to "Dialog" there.
Try "the.app:remove(the.app.frogface)"

brwiz

unread,
Dec 10, 2012, 11:05:21 AM12/10/12
to libzo...@googlegroups.com
this worked! thanks for helping out a person who's new to this.

Berzee

unread,
Dec 10, 2012, 9:18:38 PM12/10/12
to libzo...@googlegroups.com
np =) both of those problems I'd recently solved, so they were still fresh =P
Reply all
Reply to author
Forward
0 new messages