#Unable to find instance for object index -4

23 messages · Page 1 of 1 (latest)

wet egret
#

help i dont know what this error means

error:


___________________________________________
############################################################################################
ERROR in
action number 1
of  Step Event0
for object oBattle:

Unable to find instance for object index -4
 at gml_Script_BattleStatePerformAction_gml_Object_oBattle_Create_0 (line 95) -                                           instance_create_depth(currentTargets[i].x, currentTargets[i].y, currentTargets[i].depth-1, oBattleEffect ,{sprite_index : currentAction.effectSprite});
############################################################################################
gml_Script_BattleStatePerformAction_gml_Object_oBattle_Create_0 (line 95)
gml_Object_oBattle_Step_0 (line 1) - battleState();

code:
oBattle create event

function BattleStatePerformAction() 
{
    //if animation etc is still playing 
    if (currentUser.acting)
    {
        //when it ends, perform action effect if it exists 
        if (currentUser.image_index >= currentUser.image_number -1)
        {
            with (currentUser)
            {
                sprite_index = sprites.idle;
                image_index = 0; 
                acting = false;
            }
            
            if (variable_struct_exists(currentAction, "effectSprite"))
            {
                if (currentAction.effectOnTarget == MODE.ALWAYS) || ((currentAction.effectOnTarget == MODE.VARIES) && (array_length(currentTargets) <= 1) )
                {
                    for (var i = 0; i < array_length(currentTargets); i++)
                    {
                        instance_create_depth(currentTargets[i].x, currentTargets[i].y, currentTargets[i].depth-1, oBattleEffect ,{sprite_index : currentAction.effectSprite});
                    }
                }
                else //play it at 0,0
                {
                        var _effectSprite = currentAction.effectSprite
                        if (variable_struct_exists(currentAction, "effectSpriteNoTarget")) _effectSprite = currentAction.effectSpriteNoTarget;
                        instance_create_depth(x,y,depth-100, oBattleEffect, {sprite_index: _effectSprite});
                }
            } currentAction.func(currentUser, currentTargets);
        }
    }
    else //wait for delay and then end the turn
    {
        if (!instance_exists(oBattleEffect))
        {
            battleWaitTimeRemaining--
            if (battleWaitTimeRemaining == 0)
            {
                battleState = BattleStateVictoryCheck;
            }
        }
    }
}```

oBattle Step event:
```gml
battleState();```
tribal sluice
#

currentTargets[i] has noone in it

#

which is a constant for -4

wet egret
#

what

#

oh?

tribal sluice
#

yeah

#

show us how you put stuff in the currentTargets array

wet egret
#

uh

#

||i dont know||

#

i think is

#

currentTargets[i] = stuff?

#

or you mean in the code

tribal sluice
#

yes

wet egret
#

i dont?

tribal sluice
#

you dont put anything in the currentTargets array?

wet egret
#

i pressed control shift f

#

let me look again in the code

#

i misspelled it-

tribal sluice
#

okay show us how you put things into _targets

wet egret
#

its solved now

wet egret
#

i dont... again