ItsMods

Full Version: Remove HUD element
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
(09-14-2011, 06:57)AZUMIKKEL Wrote: [ -> ]HudLevelName[self.pers["LVL"]-1]

which, let's say, would be

HudLevelName[2] is just a hud element.

When the function is first called, if self.pers["LVL"] is 0, then you would create two elements with index's 0 and 1. Then, in the for loop, you write

PHP Code:
if(ret == "powerup_kill")
{
        
HudLevelName[self.pers["LVL"]-1delete();
        
/* Code snipped */


Wouldn't that reference the -1 index? I don't know if I'm missing something, it's just quite confusing Tongue
Like OrangePL said, have you tried destroyElem?
self.pers["LVL"] starts at and doesn't go any lower than 1.

I'll try destroyElem when I get home.
Where is 'HudLevelName' declared as an array?

Also, you need to add elements to the array starting at 0, and if 'self.pers["LVL"]' never goes below 1, then this won't happen.
Also, your code confuses me. First you declare HudLevelValue as a HUDElem (fontstring) and then you try to change the alpha by accessing it like an array? wtf.
It should look like this:
Code:
HudLevelValue.alpha = 1; //Kinda useless anyway, a HUDElem has an alpha of 1 by default

At the start of your code you had this:
I'm assuming that the current value of self.pers["LVL"] at that point is 1.
Code:
HudLevelName[self.pers["LVL"]] = self createFontString( "objective", 3 );
so really, it's this:
Code:
HudLevelName[1] = self createFontString( "objective", 3 );

Then you try to execute this.
Code:
HudLevelName[self.pers["LVL"]-1] delete();
which really is this:
Code:
HudLevelName[0] delete();

The reason it probably has a lag spike is because HudLevelName[0] is never declared.... Bad usage of arrays is bad. I don't even see where self.pers["LVL"] is incremented or anything...

Also this:
Code:
if(isDefined(HudLevelName[self.pers["LVL"+1]])) //Bad syntax, probably will try to access self.pers["LVL1"]

----

If you could let me see the mod I could probably help but otherwise there's not enough code there to give an accurate fix.
(09-14-2011, 11:43)master131 Wrote: [ -> ]Also, your code confuses me. First you declare HudLevelValue as a HUDElem (fontstring) and then you try to change the alpha by accessing it like an array? wtf.
It should look like this:
Code:
HudLevelValue.alpha = 1; //Kinda useless anyway, a HUDElem has an alpha of 1 by default

At the start of your code you had this:
I'm assuming that the current value of self.pers["LVL"] at that point is 1.
Code:
HudLevelName[self.pers["LVL"]] = self createFontString( "objective", 3 );
so really, it's this:
Code:
HudLevelName[1] = self createFontString( "objective", 3 );

Then you try to execute this.
Code:
HudLevelName[self.pers["LVL"]-1] delete();
which really is this:
Code:
HudLevelName[0] delete();

The reason it probably has a lag spike is because HudLevelName[0] is never declared.... Bad usage of arrays is bad. I don't even see where self.pers["LVL"] is incremented or anything...

Also this:
Code:
if(isDefined(HudLevelName[self.pers["LVL"+1]])) //Bad syntax, probably will try to access self.pers["LVL1"]

----

If you could let me see the mod I could probably help but otherwise there's not enough code there to give an accurate fix.

HudLevelName[self.pers["LVL"]] is a HUD element
HudLevelName[self.pers["LVL"]].alpha is changing the .alpha of the HUD element
I don't want to change the settings or delete every HUD element in the array, so
HudLevelName.alpha is BAD.
HudLevelName[self.pers["LVL"]-1] delete(); will never be called if the level is not above 1.


Meh.
If you can't make HUD elements with an array, I'll just go spend a couple more hours on coding a new HUD Fuu
have you tried destroyelem?
(09-14-2011, 15:28)OrangePL Wrote: [ -> ]have you tried destroyelem?

Causes spike too.
WHAT IS THIS BULL?

http://pastebin.com/Tvn2cRBL
ctrl+f for *tag*
From line 22 - 26, change: "HudLevelName[self.pers["LVL"]]" to "HudLevelName"
Pages: 1 2 3