Skip to content

Conversation

@harshasiddartha
Copy link

Description

This PR implements the requested feature from issue #8265: adding a single-argument overload to the vector function where vector(n) creates a vector with all components equal to n, equivalent to vector(n, n, n).

Changes

  • Added single-argument vector function overload in DefaultFunctions.java
  • Added comprehensive tests in ExprVectorFromXYZ.sk to verify the functionality
  • Updated documentation with examples

Motivation

This is useful for developers who require all-n vectors more easily. A common use-case would be display scale of a display entity. This is also included in many other vector libraries as a common overload.

Testing

Added tests that verify:

  • Basic cases (0, positive, negative, decimal values)
  • Random value testing (60 iterations)
  • Component equality verification

All tests follow the existing test patterns in the codebase.

Checklist

  • I have read the contributing guidelines
  • Code follows the existing code conventions
  • Tests have been added
  • Documentation has been updated

Fixes #8265

Implements vector(n) = vector(n, n, n) as requested in issue SkriptLang#8265.

This adds a convenient overload to the vector function that accepts
a single number argument and creates a vector with all components
equal to that value. This is useful for developers who require
all-n vectors, such as for display scale.

Changes:
- Added single-argument vector overload to DefaultFunctions.java
- Added comprehensive tests to verify the functionality
- Updated documentation with examples

Fixes SkriptLang#8265
@harshasiddartha harshasiddartha requested a review from a team as a code owner October 31, 2025 19:39
@harshasiddartha harshasiddartha requested review from cheeezburga and erenkarakal and removed request for a team October 31, 2025 19:39
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Oct 31, 2025
@EquipableMC
Copy link
Contributor

Make sure you're targeting dev/feature and not master

@TheMug06 TheMug06 changed the base branch from master to dev/feature October 31, 2025 20:53
@harshasiddartha
Copy link
Author

Thanks for the feedback! I've updated the PR to target dev/feature instead of master as requested.

@harshasiddartha
Copy link
Author

Hi! I see the CI checks are failing. Could you please provide more details about what's causing the build failures? The checkstyle check passed, so the code style is correct.

I've verified:

  • The function registration follows the same pattern as other functions
  • The syntax is correct
  • Function overloading is supported in Skript (as seen in the test file function overloading.sk)

The implementation adds a single-argument vector overload that creates vector(n, n, n) when called with vector(n). If there's a specific issue with the tests or the implementation, please let me know and I'll fix it!

@harshasiddartha
Copy link
Author

Updated the version from "2.13" to "2.13-pre1" as requested. The change has been pushed to the branch.

@erenkarakal
Copy link
Member

Updated the version from "2.13" to "2.13-pre1" as requested. The change has been pushed to the branch.

it should be INSERT VERSION

@harshasiddartha
Copy link
Author

Updated the version to "INSERT VERSION" as suggested. This will be filled in with the correct version during the release process.

…h same name

The Namespace.addSignature method doesn't support overloads, so we need
to check if a signature with the same name already exists before adding.
This allows function overloads to work correctly while avoiding the
'function name already used' exception.
@harshasiddartha
Copy link
Author

Fixed the build failure! The issue was that Namespace.addSignature() doesn't support function overloads (it uses only the function name as the key, not parameter types).

I've updated Functions.register() to check if a signature with the same name already exists before adding it to the namespace. This allows function overloads to work correctly - the actual function resolution happens in FunctionRegistry which properly supports overloads using parameter types.

The fix ensures that:

  • Multiple functions with the same name but different parameter counts/types can be registered
  • The FunctionRegistry (which handles actual function calls) correctly distinguishes between overloads
  • The Namespace (used for backwards compatibility) doesn't throw "function name already used" errors

Tests should now pass!

Copy link
Member

@Efnilite Efnilite left a comment

Choose a reason for hiding this comment

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

looks good!

@skriptlang-automation skriptlang-automation bot removed the needs reviews A PR that needs additional reviews label Nov 1, 2025
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution, it looks good. If you intend to continue contributing to Skript, though, I would ask you to limit your use of ai in writing comments/PR's, as it produces comments that say very little with a lot of words. Thank you!

@skriptlang-automation skriptlang-automation bot added the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label Nov 1, 2025
@sovdeeth sovdeeth moved this to Awaiting Merge in 2.14 Releases Nov 4, 2025
@sovdeeth
Copy link
Member

We cannot update this PR without you allowing us to edit the branch. Please allow access for contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.

Projects

Status: Awaiting Merge

Development

Successfully merging this pull request may close these issues.

Vector function that accepts a single argument

5 participants