S1eth wrote:
An event does not have a duration and therefore cannot be stopped. (because it has already finished the moment you call it)
The event just does a one-time change to some values. And you'd have to just call a second event that reverts these changes.
Like setting layer speedX in event A and later calling event B to set layer speedX back to 0.
While this is true, it's got me thinking. It would be neat if, in future versions of Lua, we could add this functionality. Obviously it wouldn't apply to things such as text boxes, but layer movement, etc. could work well with it. Here is how I would do it:
On triggering an event, cache two values for each memory location changed by the event - the value that location was before the event occurred, and the value it is immediately afterwards.
On calling "stopEvent" or some similar function, check that the current value of each memory location changed by the event is what we would expect it to be if the event had just been called. This would stop us from interfering with layer movement that had been subsequently changed by some other event, for example.
If it is, then revert the value to what it was just before the event was called.
There are some caveats to this method, but it should provide reasonable functionality for most use cases, and simplify this kind of thing.
Probably not a top priority, but could be neat.