diff --git a/devNotes/twine JS b/devNotes/twine JS index b964dfc6c3d43d7f43743ab0c81f9ac4762d0292..fc97687892d68f75ac4816589bb024a314e96876 100644 --- a/devNotes/twine JS +++ b/devNotes/twine JS @@ -6872,6 +6872,12 @@ window.addSlave = function addSlave(slave) { }; window.removeSlave = function removeSlave(index) { + delete State.variables.slaveIndices[State.variables.slaves[index].ID]; + for (var key in State.variables.slaveIndices) { + if (State.variables.slaveIndices[key] > index) { + State.variables.slaveIndices[key] -= 1; + } + } return State.variables.slaves.deleteAt(index); }; diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw index a512af24f9ff0af0b9a91696e53a72ab65ffc193..d32802dc7fce45330a32fcf8e6efccc7f8835397 100644 --- a/src/init/storyInit.tw +++ b/src/init/storyInit.tw @@ -71,7 +71,6 @@ You should have received a copy of the GNU General Public License along with thi <<set $slaves[_i].rivalry = 0, $slaves[_i].rivalryTarget = 0, $slaves[_i].subTarget = 0>> <<else>> <<set _dump = removeSlave(_i), _i--, _SL-->> - <<set $slaveIndices = slaves2indices()>> <</if>> <</for>> <<for _k = 0; _k < _SL; _k++>> diff --git a/src/js/assayJS.tw b/src/js/assayJS.tw index 875af5ad2091361e7b2dfe36def6eed6f278e0ab..797f19d48addd7f94c8165a039e5fd802bbd2f17 100644 --- a/src/js/assayJS.tw +++ b/src/js/assayJS.tw @@ -221,6 +221,12 @@ window.addSlave = function addSlave(slave) { }; window.removeSlave = function removeSlave(index) { + delete State.variables.slaveIndices[State.variables.slaves[index].ID]; + for (var key in State.variables.slaveIndices) { + if (State.variables.slaveIndices[key] > index) { + State.variables.slaveIndices[key] -= 1; + } + } return State.variables.slaves.deleteAt(index); }; diff --git a/src/npc/removeActiveSlave.tw b/src/npc/removeActiveSlave.tw index b510a25eeaa34b51254c7e1b94b107639124d38d..2183e06c3a84d87198a0400648d758ecddf69818 100644 --- a/src/npc/removeActiveSlave.tw +++ b/src/npc/removeActiveSlave.tw @@ -144,7 +144,6 @@ <</if>> <<set _dump = removeSlave(_x), _SL--, $activeSlave = 0>> - <<set $slaveIndices = slaves2indices()>> <<if _missingID == 1>> <<set $missingParentID-->>