I'm very much a beginner when it comes to puzzlescript, so I didn't really use some lines of code to do the whole thing. I basically just programmed every single combination of things that can happen. Which heart gets filled based off the hearts that are empty, which heart becomes empty, which heart gets filled when one empty heart is blocked by an object, etc. It's extremely messy and very inconvenient when trying to fix bugs, but it works.