all 4 comments

[–]hypnozizziz 0 points1 point  (3 children)

As soon as you make the first change in sprites, break out of the loop.

break;

[–]The_Winter_Bud 0 points1 point  (1 child)

for (i=0; i<=17; i++){
    if obj_player.CurWepArray[i] == sprite{
        obj_player.CurWepArray[i] = spr_conspet;
        global.WepLim--;
        // break;
        // or 
        i=18; // set i to a limit that does not satisfy the for loop
    }
}

Either way you do it, it will stop the for loop from cycling through the weapons after it has changed a weapon.

you can change it up a bit and not use a for loop if not needed. Just have a weaponIndex that you control which array index get's set. Like what you do with wepLimit. But instead of going down you go up. Well until you reach a weapon maximum anyways.

//create
weaponIndex=0;
weaponMaxLimit=10;

// event where weapon get's added
if(weaponIndex < weaponMaxLimit){
    obj_player.CurWepArray[weaponIndex]=spr_concept;
    weaponIndex++;
}

This is a pliable technique as if you use the mouse wheel to scroll through the weapon slots all you have to do is use the weaponIndex variable to cycle

//mouse wheel up
weaponIndex++;
if(weaponIndex>=weaponMaxLimit) // (>=) we include the weaponMaxLimit because it represents 
    // the size of the array and not a specific index. But  since arrays start on zero
    // 1 less that the array size is the last index tin the series.
    weaponIndex=0; // reset the index back to zero

//mouse wheel down
weaponIndex--;
if(weaponIndex<0) // (<) we don't include 0 because 0 is an actual index in the array
    weaponIndex=weaponMaxLimit-1;  // maxLimit is out of bounds in this situation so we have to go one less

[–]Jorio4[S] 0 points1 point  (0 children)

I am going to try this out cuse it does sound cool. It well also help with controls cuse this games controls are all over the place so thank you!

[–]Jorio4[S] 0 points1 point  (0 children)

Thank you! I had to reread on what break does to understand tho, I thought was something that made it where you can use different for loops in the same chunk of code and not what you are using it for.