View Single Post
  #1  
Old 06-07-2011, 04:35 AM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Help with a for loop problem?

Okay so, I'm using a for loop to check through a multi-dimensional array, and everything is returning fine, the script is basically doing what I want it to do, no problem. But now within the for loop i'm trying to set an individual this.whatever flag everytime I mouse over an object in the array. (If this makes sense?) But for some reason, I can only set the flag for the last group of variables in the array.. ?

I dunno if what I just said makes any sense, but either way, check out the code and you'll probably see what I mean.. By the way, I am merely providing the pieces of the code that are needed in order for me to get help, the //Mouse Over part is being ran within a timeout loop just to clarify things a bit more..

Also, another clarification: I'm trying to set this.newDebug to true everytime the mouse enters the specified zone, but I can only set it for the "Rifle" array part. It won't set for any others. =/

Thanks in advance to anyone that helps.

PHP Code:
function onCreated()
{
  
this.equipSlots = { {"Hat", 36, 58, "necro_gui_equips-hat.png"},
                      {
"Mask", 96, 58, "necro_gui_equips-mask.png"},
                      {
"Armor", 156, 58, "necro_gui_equips-armor.png"},
                      {
"Back Piece", 36, 118, "necro_gui_equips-back.png"},
                      {
"Shirt", 156, 118, "necro_gui_equips-shirt.png"},
                      {
"Glove", 36, 178, "necro_gui_equips-glove.png"},
                      {
"Pants", 156, 178, "necro_gui_equips-pants.png"},
                      {
"Shoes", 96, 209, "necro_gui_equips-shoes.png"},
                      {
"Explosive", 36, 233, "necro_gui_equips-explosive.png"},
                      {
"Left Weapon", 36, 288, "necro_gui_equips-leftwep.png"},
                      {
"Right Weapon", 156, 288, "necro_gui_equips-rightwep.png"},
                      {
"Rifle", 96, 264, "necro_gui_equips-rifle.png"}
                   };
  
this.equipSlotCount = 12;
}

    
//Mouse over for Slot
    
temp.mouse_xy = {mousescreenx, mousescreeny};
    for ( 
i=0; i < this.equipSlotCount; i++; ) {
      
      
temp.chSlots = this.equipSlots[i];
      if ( 
mouse_xy[0] in |menu_xy[0] + chSlots[1], menu_xy[0] + chSlots[1] + 32| &&
           
mouse_xy[1] in |menu_xy[1] + chSlots[2], menu_xy[1] + chSlots[2] + 32| ) {
        
this.newDebug = true;
        
with ( findImg ( 203 + i ) ) {
        
          
image = chSlots[3];
          
x = menu_xy[0] + chSlots[1];
          
y = menu_xy[1] + chSlots[2];
          
layer = 5;
          
mode = 0;
          
red = green = blue = 1;
          
alpha = .8;
        }
        
with ( findImg ( 223 + i ) ) {
        
          
text = chSlots[0];
          
font = "Tempus Sans ITC";
          
style = "bc";
          
x = menu_xy[0] + chSlots[1] + 16;
          
y = menu_xy[1] + chSlots[2] - 5;
          
layer = 5;
          
mode = 0;
          
red = green = blue = 1;
          
alpha = .8;
          
textshadow = true;
          
shadowcolor = {0, 0, 0};
          
zoom = .6;
        }
      } else {       
        
hideImg( 203 + i ); 
        
hideImg( 223 + i ); 
        
this.newDebug = false;
      }
    } 
Reply With Quote