Topic: My HUD object keeps having seizures

Okay. That wasn't a good title, but I keep getting weird jerky effects with a HUD object.

//HUD
//S32X/CJH3D
//Experience Counter: Tells how expirenced you are!

          object ".Expirence Checker"
   {
                always_active
                requires 0.2.0 //Revsion 709
                
             state "main"
        {
                   //constants

                  hide
                  let $experience=score()
                  change_state "loop"
        }
             state "loop"
        {
                  if $experience=10000 "change"
                  if $experience=20000 "change"
                  if $experience=30000 "change"
                  if $experience=40000 "change"
                  if $experience=50000 "change"
                  if $experience=60000 "change"
                  if $experience=70000 "change"
                  if $experience=80000 "change"
                  if $experience=90000 "change"
                  if $experience=100000 "masterchange"               
        }
             state "change"
        {
                  change_closest_object_state ".Levelup Counter" "Bumpup1"
                  change_state "wait"
                  
        }
             state "wait"
        {
                  let $experience+=1
                  change_state "loop"
        }
             state "masterchange"
        {
                  change_closest_object_state ".Levelup Counter "maseter"
                  on_timeout .4 "SHARP!
                  strong_player
        }
             state "SHARP!"
        {
             play_music "musics/sharp.ogg"
             change_state "void"
        }
             state "void"
        {
        }
   }

          object ".Levelup Counter"
   {
                   always_active
                   requires 0.2.0 //Revision 709
                   detach_from_camera
 
             state "main"
        {
              //constants
              hide
              let $level=0
              change_state "loop"
        }
             state "loop"
        {
              set_zindex "2.0"
              set_absolute_position "0" "180"
              textout "hud" 0 0 "<color=aaaaaa>Level</color>:$level"
        }
            state "Bumpup1"
        {
              let $level+=1
              play_sample "powerup"
              textout "hud" 0 0 "<color=aaaaaa>Level</color>:<color=ffff00>LEVEL UP!</color>
              change_state "cooldown"
        }
           state "cooldown"
        {
             on_timeout 1 "loop"
        }
           state "master"
        {
                  play_sample "samples/creativecommons.ogg"
                  textout "hud" 0 0 "<color=aaaaaaa>Level</color>:<color=ffff00>MASTER<color>
        }
    }

I don't see anything wrong with it. Do you?

http://upload.surgeswarehouse.com/upload/tchsig.png
My Souncloud
My YouTube Channel
My Website

Re: My HUD object keeps having seizures

Some notes:
1. When trying to compare two values using if, please use == instead of =.  == is the comparison operator, = is the assignment operator. 
2. You should likely avoid using symbols, such as !, in state names.
3. There is no need to use quotation marks around 'magic numbers' (magic numbers are numbers that are in the code that are not in a variable).
4. Your experience system could be simplified down to one if statement, specifically if $_experience == 10000*$_level .  This would require you to make those two global variables, but would give you a much larger range of levels without all the lines.
5. What triggers the void state if anything at all?

I am not sure what causes it to have seizures...I would probably have to see your whole object base to understand your interactions between objects.

And a word to the wise, when the fire dies you think it's over but it's just begun. -A7X: A Little Piece of Heaven

Re: My HUD object keeps having seizures

lunarrush wrote:

When trying to compare two values using if, please use == instead of =.  == is the comparison operator, = is the assignment operator.

I tried that and nothing happened.

lunarrush wrote:

Your experience system could be simplified down to one if statement, specifically if $_experience == 10000*$_level .  This would require you to make those two global variables, but would give you a much larger range of levels without all the lines.

I'll look into that.

http://upload.surgeswarehouse.com/upload/tchsig.png
My Souncloud
My YouTube Channel
My Website