Game Spawner System Variable Issue

P

PreviaSens

Guest
I've been working on a school project recently and earlier today when I thought I was done, this message would come up whenever my character tried to enter the spawner zone / area. I'm fairly new and I'm pretty sure this is for the collision with spawner and player code but I can't find the problem and what to change. The error message is below and below that is the code I used. If anyone could help me with this that'd be great.
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step EventoPlayer
for object oSpawner:
trying to index a variable which is not an array
at gml_Object_oSpawner_Collision_ef39636d_a338_43dc_9c03_35385172afbe (line 15) - remaining[total_waves]++;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oSpawner_Collision_ef39636d_a338_43dc_9c03_35385172afbe (line 15)

CODE USED

if (triggered == false)
{
triggered = true;

total_waves = 1;
for (var i = 0; i < ds_list_size(waves); i++)
{
var thisentry = ds_list_find_value(waves,i);
if (thisentry [_WAVE] > total_waves)
{
total_waves++;
remaining[total_waves] = 0;
}
remaining[total_waves]++;
}
}
 
E

Enegris

Guest
total_waves is saved as variable in your code with a numerical value. at line 15, you're trying to access an array, not a variable. this causes an error.
 
Last edited by a moderator:
P

PreviaSens

Guest
total_waves is saved as variable in your code with a numerical value. at line 15, you're trying to access an array, not a variable. this causes an error.
What should I put in to fix this? (Sry, I'm pretty new and don't know much)
 

FrostyCat

Member
You need to pay attention to what remaining is.

In GML, the terms "array" and "list" are NOT equivalent. If remaining is a list, you use the list accessor (which has a | character at the beginning), not the standard array notation.
Code:
remaining[| total_waves]++;
Of course, if remaining is something else entirely, you need to completely rewrite this part of the code and/or the part of the code that gives remaining its starting value, such that both agree on the data type being used.
 
Top