"lsme" not working properly
valanths1990 opened this issue · comments
valanths1990 commented
"lsme"-> { //load and spawn selected on me
this command have issue,
you must keep a reference of bot list, if you dont, coroutine will be executed async but list is cleared before execution
according to your code should be like that:
val bots = ViewStates.indexViewState(activeChar).selectedBots.filter { !it.value.isOnline }
CoScopes.generalScope.launch {
bots.forEach {
innerLaunch@CoScopes.massSpawnerScope.launch {
val autobot = AutobotsDao.loadByName(it.value.name) ?: return@innerLaunch
autobot.setXYZ(activeChar.x + Rnd.get(-150, 150), activeChar.y + Rnd.get(-150, 150), activeChar.z)
AutobotsManager.spawnAutobot(autobot)
}
}
}
ViewStates.indexViewState(activeChar).selectedBots.clear()
Nick Chapsas commented
You're right, i remember fixing this at some point. It needs to be async since it can be quite a few bots that you are creating but I can't remember what I did to fix it. Will scan through the private repo and see if I can find it.
valanths1990 commented
In the code i post it fixes that problem
Nick Chapsas commented
Ah yeah I fixed it like that for the dess command. Thanks I committed it.