-
[F8] Array issues
I have this code.
Code:
var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
weapon_delay[i]=parseInt(r.result);
if i trace r.result it will come up with the right value, but when i trace weapon_delay[1] it comes up as undefined.
there should be 4 values in weapon_delay.
-
Senior Member
what happens if you do this?
Code:
var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
weapon_delay[0]=parseInt(r.result);
-
-
what is: r.result? Make sure it's just a number not any extra spaces or anything.
-
r.result is {4,20,30,3}
here is a whole chunk of the code im using incase something else is messing it up.
Code:
for(i=0;i<fileList.length;i++){
file = "data\\weapons\\"+fileList[i];
ssDebug.trace(fileList[i]);
var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"name", defaultValue:"?"});
weapon_name=r.result;
var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
weapon_delay[i]=parseInt(r.result);
ssDebug.trace(r.result+"b");
var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"image", defaultValue:"?"});
_root.projectile_speed[i]=parseInt(r.result);
var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"explosion", defaultValue:"?"});
_root.projectile_explosion[i]=parseInt(r.result);
var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"damage", defaultValue:"?"});
_root.projectile_damage[i]=parseInt(r.result);
var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"amount", defaultValue:"?"});
_root.projectile_amount[i]=parseInt(r.result);
var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"random", defaultValue:"?"});
_root.projectile_random[i]=parseInt(r.result);
var r =ssCore.INIFile.getVal({path:file, section:"Projectile", key:"speed", defaultValue:"?"});
_root.projectile_speed[i]=parseInt(r.result);
}
-
Instead of this:
weapon_delay[i]=parseInt(r.result);
use this:
weapon_delay=r.result.split(",");
this will separate all of the numbers in r.result and place them into the array. No loop necessary because it will separate the whole string at once.
-
but it only loads 1 file at a time.
so each time the loop is run is run r.result is 4
2nd time it is 20
so on.
-
ok, what i will do is make it a string and do this:
Code:
var r =ssCore.INIFile.getVal({path:file, section:"Weapon", key:"delay", defaultValue:"?"});
weapon_delay+=","+parseInt(r.result);
then split that up.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|