chardata.weapons.splice(weapon_idx, 1);
does not "reorder" the array. Eg.,
[{foo}, {bar}, {monkey}].(splice(1))
does not just create [{foo}, {monkey}]. It's stored as
["0":{foo}, "2":{monkey}]
which causes a problem with the way I'm handling the UI. My solution was to copy the array with slice(), then reassign it back to the real chardata object:
chardata.weapons.splice(weapon_idx, 1);
var foo = chardata.weapons.slice();
chardata.weapons = foo;
The indexes are sequential with no gaps. Weird, but it works.
No comments:
Post a Comment