This code allows Mario to summon the closest carryable sprite, horizontally, into his hands. The closest sprite will be put into his hands instantly as long as he isn't already holding something, and it will also detect kicked sprites. Could be useful for puzzle levels, or Kaizo levels involving summoning sprites in a tight order to perform specific tricks. Summon is performed by holding X or Y (by default), then tapping L or R.
Please give credit if used. Usage note: If using in your hack, it may be wise to let the player know that it only measures horizontal distance, not vertical.
Update v1.1: Bug fixes, and made some of jankier "featues" of the code into optional defines. Also made a few small optimizations, moved the SFX/Bank to defines, and allowed the user to customize the hold input.
Most of this code seems to work as intended, but there's a notable flaw with springs. By timing it a certain way (ask for a video if you want one), if you bounce on the spring while trying to summon it to you, a second spring will spawn in its place, duplicating it in the process. From my testing I could only get two springs this way, although it could probably be chained more. This problem also only seemed to occur on the non SA-1 version, which was odd. It may have been how my test level was set up between the two, but regardless sprite duplication is a problem. After that's fixed this should be good for approval.