Page 1 of 1

Removed Entity

Posted: July 6th, 2011, 10:01 am
by Opel
Hey guys, i don't get what is wrong with my code. I get an error saying "Removed entity is not an entity" with this line:

Code: Select all

self.stats[0] setValue(self.jmp["stats"]["saves"]);

Code: Select all

drawStats()
{
        self endon("disconnect");
        self endon("joined_spectators");
        self endon("death");
        
        self.stats = []; 
        
        self.stats[0] = newClientHudElem(self);
        self.stats[1] = newClientHudElem(self);
        self.stats[2] = newClientHudElem(self);
 
        self.stats[0].x = 350;
        self.stats[1].x = 350;
        self.stats[2].x = 350;
                
        self.stats[0].y = 100;
        self.stats[1].y = 115;
        self.stats[2].y = 130;
        
        self.stats[0].label = &"Saves: ";
        self.stats[1].label = &"Loads: ";
        self.stats[2].label = &"Bounces: ";
        
 
        for( i = 0; i < self.stats.size; i++ )
        {
                self.stats[i].alignX = "center";
                self.stats[i].alignY = "middle";
                self.stats[i].horzAlgin = "center";
                self.stats[i].vertAlgin = "top";
                self.stats[i].fontscale = 1.4;
                self.stats[i].hideWhenInMenu = true;
        }
 
        self thread updateStats();
}
 
updateStats()
{       
        self endon("disconnect");
        
        while(1)
        {
                wait 0.05;
        
                if( isDefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
        
                if( isDefined(self.jmp["stats"]["loads"]))
                        self.stats[1] setValue(self.jmp["stats"]["loads"]);
        }
        wait 0.05;
}
 
clearHuds()
{       
        for( i = 0; i < self.stats.size; i++ )
        {
                if(isDefined(self.stats[i]))
                        self.stats[i] destroy();
        }
}
 

Re: Removed Entity

Posted: July 6th, 2011, 10:26 am
by IzNoGoD
How do you call this code?
I think you use self the wrong way...

Else, try this:

Code: Select all

 
                if( isDefined(self.jmp) && isdefined(self.jmp["stats"]) && isdefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
        
                if( isDefined(self.jmp) && isdefined(self.jmp["stats"]) && isdefined(self.jmp["stats"]["loads"]))
                        self.stats[1] setValue(self.jmp["stats"]["loads"]);

Re: Removed Entity

Posted: July 6th, 2011, 11:40 am
by Opel
Thanks for the help but it didn't seem to fix it, but i did manage to fix it by replacing

Code: Select all

if( isDefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
with

Code: Select all

if( isDefined(self.stats[0]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);

Re: Removed Entity

Posted: July 6th, 2011, 11:54 am
by IzNoGoD

Code: Select all

 
updateStats()
{       
        self endon("disconnect");
        self endon("stop_updating");
        while(1)
        {
                wait 0.05;
        
                if( isdefined(self.stats[0])&&isDefined(self.jmp["stats"]["saves"]))
                        self.stats[0] setValue(self.jmp["stats"]["saves"]);
        
                if( isdefined(self.stats[1])&&isDefined(self.jmp["stats"]["loads"]))
                        self.stats[1] setValue(self.jmp["stats"]["loads"]);
        }
        wait 0.05;
}
 
clearHuds()
{       
        self notify("stop_updating");
        for( i = 0; i < self.stats.size; i++ )
        {
                if(isDefined(self.stats[i]))
                        self.stats[i] destroy();
        }
}
Added some stuff
Should work, even with the old line you used.

Re: Removed Entity

Posted: July 7th, 2011, 7:19 pm
by Drofder2004
It has been a while since I have tested it, but I believe all HUDs should be initialised and followed by a 'wait 0.05;' to allow time for the HUD to be created, before any stats are passed. Although, I could be wrong.

Re: Removed Entity

Posted: July 7th, 2011, 8:41 pm
by IzNoGoD
Drofder2004 wrote:It has been a while since I have tested it, but I believe all HUDs should be initialised and followed by a 'wait 0.05;' to allow time for the HUD to be created, before any stats are passed. Although, I could be wrong.
You are wrong :)

Re: Removed Entity

Posted: July 8th, 2011, 12:17 am
by Drofder2004
IzNoGoD wrote:
Drofder2004 wrote:It has been a while since I have tested it, but I believe all HUDs should be initialised and followed by a 'wait 0.05;' to allow time for the HUD to be created, before any stats are passed. Although, I could be wrong.
You are wrong :)
Noted.