see thats wat i thot, i was just getting rid of the reference, but the object still there, and we both right the object still on the MapEntityList, my problem is actually a really old one, its one i had over a year ago when i started doing this whole turn based thing, ill try to be as succinct as i can.
function NewUpdateScript() {
for ( i in MapEntityList ) {
MapEntityList[i].update()
}
if ( Combat == true ) {
Combat.process()
}
for ( i in MapEntityList ) {
if ( MapEntityList[i].erase == true ) {
DestroyPerson(MapEntityList[i].personsname)
MapEntityList.splice(i, 1)
}
}
}
altho this is an oversimplification, this is the basic layout of the problematic area. what happens is i get a MapEntityList @ index has no properties bug. so i switched to a regular for loop
for ( var i = 0; i >= MapEntityList.length; ++i ) {
//if, DestroyPerson and .splice here
}
and then the for loop never runs
EDIT: ok i changed it up a bit... its the .splice of an array inside a loop looking at that array right?
function NewUpdateScript() {
for ( i in MapEntityList ) {
MapEntityList[i].update()
}
if ( Combat == true ) {
Combat.process()
}
var cleaning = false
var cleanindex = 0
var mapclean = false
while ( mapclean == false ) {
for ( i in MapEntityList ) {
if ( MapEntityList[i].erase == true ) {
cleaning = true
cleanindex = i
break
}
}
if ( cleaning == true ) {
DestroyPerson(MapEntityList[cleanindex].p)
MapEntityList.splice(cleanindex, 1)
cleaning = false
} else {
mapclean = true
}
}
it seems like way over complicating it, but any other way wont work right?