Crash without message when calling enemy:restart() from on_removed
Created by: Renkineko
Here you have an example script of a generator of enemies. It will pop a tentacle, and when you kill it, the enemy restart. If, when you have the tentacle summoned, you quit the map or if you reload the game via quick debug key (F1 to F3 on ZSDX), the game crash without message nor alert.
Engine version : 1.2
function enemy:on_restarted()
print('Wait a little...')
-- if you want to test after you killed the tentacle...
sol.timer.start(enemy, 2500, function()
local tentacle = enemy:create_enemy({breed = 'tentacle', x = -20, y = -20})
print('You can now load the game with F[1-3] key or quit the map to crash')
function tentacle:on_removed()
print('If you reload the game or quit the map now, you will not have a crash...')
enemy:restart()
end
end)
end