more efficient way to do this?
Posted: Thu Feb 19, 2009 1:08 am
I have a really basic script, it works, however I know there's a more efficient way to write it.
For example:
Basically its taking a chunk value and finding its attack and defense value. The only problem is it has to go down a huge list of weapons and compare each value until it finds the correct one.
So basically what I want to do is associate some numbers with different $attack and $defense values, so the script will jump straight to the assigned value. If that's even possible.
When I searched the forum I found a bit about associative arrays. I think that might be my solution but I'm not sure.
I'll keep researching this, but any point in the right direction will be very helpful.
Thanks,
-C
For example:
Code: Select all
if($weapon[6] == 52){
$attack=50;
$defense=50;
}elseif($weapon[6] == 51){
$attack=40;
$defense=40;
}elseif($weapon[6] == 50){ ...etc
So basically what I want to do is associate some numbers with different $attack and $defense values, so the script will jump straight to the assigned value. If that's even possible.
When I searched the forum I found a bit about associative arrays. I think that might be my solution but I'm not sure.
I'll keep researching this, but any point in the right direction will be very helpful.
Thanks,
-C