Skip to content

ExprMidpointLocations #7888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: dev/feature
Choose a base branch
from

Conversation

Absolutionism
Copy link
Contributor

@Absolutionism Absolutionism commented May 22, 2025

Problem

Currently is no quick and easy route of getting the center location from two locations.
The only current way I know to achieve this, is
set {_center} to {_loc1} ~ ((vector from {_loc1} to {_loc2}) / vector(2,2,2))

Solution

Adds ExprCenterLocations that does this.

Testing Completed

ExprCenterLocations.sk


Completes: none
Related: none

@Absolutionism Absolutionism requested a review from a team as a code owner May 22, 2025 17:28
@Absolutionism Absolutionism requested review from cheeezburga and erenkarakal and removed request for a team May 22, 2025 17:28
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label May 22, 2025
@ShaneBeee
Copy link
Contributor

Just going to throw my 2 cents in here.
This in my opinion seems like bloat.

Skript should focus on the language and the Bukkit API itself.

Skript shouldn't be putting on focus on doing math that a Skript user could do themselves.
This feels more like something meant for an addon.

Again, I repeat, just my opinion.

@sovdeeth
Copy link
Member

sovdeeth commented May 22, 2025

I'm kind of ambivalent on this, since it seems like a really easy thing to do with existing tools. It's a bit clunky since you have to get a vector or do math on x/y/z, though, so i see the appeal of a simpler manner. I don't mind it either way.

That said, I'm strongly against calling it the center point. I think that muddles the waters between the existing center expression (and could cause syntax conflicts as is currently written). I would stick entirely to the term midpoint for this.

I'd like to comment that the pr template does ask you to argue why the given problem needs solving, and I think just the fact that no QOL expression exists is not reason enough. I'd like to see some arguments as to why it needs to be added and why it's better than whatever you can currently do.

This is also missing any documentation of testing completed.

@Absolutionism
Copy link
Contributor Author

So you want only [the] midpoint (between|of) %location% and %location% + from ... to ...

@sovdeeth
Copy link
Member

sovdeeth commented May 22, 2025

So you want only [the] midpoint (between|of) %location% and %location% + from ... to ...

well midpoint from x to y doesn't make much sense, but the between/of seems fine, yes
(also fyi you can divide the vector by 2 directly, instead of using a vector of 2s)

@sovdeeth sovdeeth added the feature Pull request adding a new feature. label May 22, 2025
@Absolutionism Absolutionism requested a review from sovdeeth May 22, 2025 20:58
@Absolutionism Absolutionism changed the title ExprCenterLocations ExprMidpointLocations May 24, 2025
@Absolutionism Absolutionism requested a review from sovdeeth May 25, 2025 14:02
Comment on lines +48 to +51
Class<?> type1 = object1.canReturn(Location.class)
? Location.class : (object1.canReturn(Vector.class) ? Vector.class : null);
Class<?> type2 = object2.canReturn(Location.class)
? Location.class : (object2.canReturn(Vector.class) ? Vector.class : null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the best way to approach this. Consider midpoint between {_vec} and vector(1,2,3). Wouldn't {_vec} be able to return a location?

Object object2 = this.object2.getSingle(event);
if (object1 == null || object2 == null) {
return null;
} else if (!parseCheck) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checks need to be done regardless, the parse check is not air-tight

@skriptlang-automation skriptlang-automation bot removed the needs reviews A PR that needs additional reviews label May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants