Dealing with 3D arrays of lists and run-time error
BlitzMax Forums/BlitzMax Programming/Dealing with 3D arrays of lists and run-time error
| ||
Anyone know why I might be getting the run-time error: Unhandled Exception:Attempt to access field or method of Null object With this code 'at the head of the Type Field Map:TList[,,] 'In a constructor for the Type Map = New TList[X+1,Y+1,Z+1] 'In a method for the type Map[Entity.MapX,Entity.MapY,Entity.MapZ].AddFirst(Entity) I've simplified this pretty harshly. The constructor is a function that assembles a new object and then returns it. The actual code there, if it matters, is: Ma.Map = New TList[Ma.X+1,Ma.Y+1,Ma.Z+1] I'm sure I'm just being a moron. Also, hello everyone, long time no see. ::EDIT:: OK, so I am a moron. LOL If Map[Entity.MapX,Entity.MapY,Entity.MapZ] Map[Entity.MapX,Entity.MapY,Entity.MapZ].AddLast(Entity) Else Local list:TList = New TList list.AddLast(Entity) Map[Entity.MapX,Entity.MapY,Entity.MapZ] = list EndIf I assumed the lists were already created when the array was created. Silly me. Last edited 2011 Last edited 2011 |