I get this error

L

LawH

Guest
Push :: Execution Error - Variable Index [1,0] out of range [1,-1] - -1.array_traits(100285,32000)
at gml_Object_obj_p1_StepNormalEvent_6 (line 25) - if array_traits[trait_number,0] == 1 {

I have a 2d array. Here is a snippet of what I am doing with it:

trait_number = 0;
if array_traits[trait_number,0] == 1 {
simple = false;
array_traits[trait_number,0] = 1;
array_traits[trait_number,1] = "Intelligent";
array_traits[trait_number,2] = TraitVis.Interact; }
else if array_traits[trait_number,0] == -1 {
intelligent = false;
array_traits[trait_number,0] = -1;
array_traits[trait_number,1] = "Simple";
array_traits[trait_number,2] = TraitVis.Interact; }
else {
array_traits[trait_number,0] = 0;
array_traits[trait_number,1] = "Average";
array_traits[trait_number,2] = TraitVis.Interact; }

trait_number += 1;
if array_traits[trait_number,0] == 1 {
challenged = false;
array_traits[trait_number,0] = 1;
array_traits[trait_number,1] = "Gifted";
array_traits[trait_number,2] = TraitVis.Know; }
else if array_traits[trait_number,0] == -1 {
gifted = false;
array_traits[trait_number,0] = -1;
array_traits[trait_number,1] = "Challenged";
array_traits[trait_number,2] = TraitVis.Know; }
else {
array_traits[trait_number,0] = 0;
array_traits[trait_number,1] = "Average";
array_traits[trait_number,2] = TraitVis.Know; }


After every new trait being checked, the trait_number increases by 1, and it goes on until all the traits are checked in this same way. Line 25, where the error is, is in this part of the code.

Not sure what the error means so any info would be great.

Can I not have negative numbers as values in arrays? And if so, why does the first one run fine, but then at the second one I get an error?

In addition, this code worked fine until I started checking from an array, rather than checking from individual variables.
 
Last edited by a moderator:
L

LawH

Guest
When did you put the values into the array in the first place?
I think that might have been the problem, since I put it in a script but I think I failed to add it. Thanks! I'll return if the problem persists.
 
Top