This code will add a short cooldown to the ON/OFF switches to prevent Mario or sprites to trigger two of them at the same time. Unlike the patch version, this will also work with custom ON/OFF switches.

You can increase the cooldown in the asm file (you may want it higher if used in a water level or if you want switches triggered by cape twirls).