This is a part of a project I'm working on, the Layertoy project! The Layertoy project is a series of libraries dedicated to niche layer movement scripting. Most of the Layertoy scripts I develop will be based on Layer 2 mechanics from SMW and SMW ROM Hacks! Or some custom ideas, if anyone would like to see an idea!
NOTE ABOUT REQUESTS: I will put them on my list but I won't do the code immediately right away, unless it's urgent and really easy to develop. You can check what Layertoy projects I'll be developing on my forum signature!!
https://imgur.com/a/uU94ivY
Anyway, what's this? This is a library that lets you control the movement of a layer whenever you're holding a specific item.
Change those values that are not in brackets to set the speed. They need to be the same value for the movement to be synchronized.
holdlayer.triggertable: If you've read or used Stickykeys.lua before, it works the exact same way here. This is a table where you can register NPC ids that when you hold them, they affect the layer.
holdlayer.triggertable[114] = true -- registers the red koopa shell
holdlayer.setverticalorder(newvalue)
A function for inverting the negative y and positive y movement of the layer without changing the values manually.
For example, holding an item when it's set to true will make the layer go up.
But if it's set to false, the layer will go down.
In order to avoid any weird edge case or issues with this variable, you can't invert the layer direction until it's back to its origin point.
NOTE ABOUT TIMERS:
Since layers have no definition of position, a timer that increments every tick and variables with a positive and negative value that is the same is used here in order to mimick a definition of position.