Push X towards Y
Problem
It's quite common for users to want to push one entity towards another, or towards a specific location. This isn't very hard, it's push {_X} along (vector from {_x} to {_y}), but it's not immediately obvious. The main reason is that the pattern is push %entities% [along] %direction% and it's not explained that a vector is also a direction.
This also has another weakness: pushing multiple entities towards the same point. This requires a loop over the entities to calculate the vector for each one.
Solution
I've added syntax to make it more intuitive and efficient to do this: push %entities% (away from|towards) %location%. Internally, it acts the same as push {_X} along (vector from {_x} to {_y}), it's just simpler for the user and more accessible for those unfamiliar with directions/vector interplay.
I've made two possibly controversial choices that I'd like opinions on:
- This mirrors the previous solution by not normalizing the direction vector if no speed is applied. This is faster and prevents double-normalization when speed is provided, but it also may be confusing for new users who go flying off into outerspace when their target location is 20 blocks away.
- I have treated the location as if it is always within the same world as the entity being pushed towards it. This makes the code a lot cleaner and removes some annoying checks. I'm of the opinion that pushing towards a different world's location is a really rare mistake to make, and that if it is made, treating it as if it's the same world isn't likely to be very confusing. The only case I can see this being an issue is if someone tries to rely on it not working to only push people in the same world, which sounds extremely uncommon.
Testing Completed
Added EffPush.sk
Supporting Information
I am counting this as completing https://github.com/SkriptLang/Skript/issues/1671, as though it isn't a direction, it is fulfilling the requested behavior. I didn't want to make this a direction because I feel directions are already a bit bloated and hard to understand, and that it wouldn't really reduce the confusion around how to do this task.
Completes: #1671 Related: none