That said, it's not perfect. There are edge cases that this code may not account for. Please read the notice at the end of the post for more information.
Recommended for use in one-screen puzzle levels primarily.
Download:
https://pastebin.com/TLkGsyrp
Demo:
Load the library and it works by default!
Customization options:
resetdoors.blacklistNPCS({list of npc ids}) will exclude those IDs from resetting
resetdoors.whitelistWarps({list of warp ids}) will whitelist those IDs as reset doors. If NO warps are whitelisted, ALL warps are reset doors. Even instant warps and pipes.
resetdoors.blocks = true/false - toggles block resets (default true)
resetdoors.npcs = true/false - toggles npc resets (default true)
NOTICE AT THE END OF THE POST
This is a demo.
You might encounter crashes with certain new NPCs.
This might have lag spikes in large levels/large sections with a lot of NPCs.
KNOWN EDGE CASES (will be fixed in the future):
-Enemies that are still spawned but have fallen out of the section will not respawn until their natural despawn.
-Paddlewheels break!
-By extension, everything with orbits breaks!
-New springs break!
-more?
Please report any breaks you find with this in this thread because finding new NPCs that break from this help find faulty code with the NPCs themselves! Sneaky bugs.