You can also define the function that's called when enemies are killed. Assuming the enemies are named "chest_enemy_1", "chest_enemy_2", etc, then
function chest_enemy_1:on_killed()
if not map:has_entities("chest_enemy") then
chest:set_enabled(true)
end
end
You'll have to define that for all the chest enemies since you don't know which will be killed first. You can copy the code, or use a for loop, if you know those. Like
for x in map:get_entities("chest_enemy") do
function x:on_killed()
--check if other enemies exist
end
end
I don't remember offhand if the function should be on_killed or on_dead, so check the API docs