Skip to content

Conversation

@sovdeeth
Copy link
Member

@sovdeeth sovdeeth commented Dec 7, 2025

Problem

I sincerely apologize for shoving three four different PRs together, they just all seemed to build on each other. If one proves controversial, I'll spin it out to its own PR.

Color hex codes: The driving force for this PR. @cheeezburga's color pr, #7246, has a useful 'hex code of color' expression, which I want to use to assist in formatting chat messages based on color objects. Since that pr seems to be stale, I'm pulling it over here. I also added a color from hex expression as an inverse relationship.

Converting bases: Since we're providing hex conversion to decimal implicitly in color conversion, we should support it fully. Currently, there's no easy way to convert between bases. Users have used character x in "0123456789..." as a workaround, but it'd be nicer and easier to have it as a built-in function for many bases at once.

Ranged function parameters: The base conversion methods in Java only allow bases between 2 and 36. I wanted more robust limits on the function parameter inputs, like parse errors if the input was a literal and out of range.

Fixes to runtime error catching/simplification errors: If a element tries to simplify but encounters a runtime error, it currently just prints that error and whatever output is used for the simplification, leading to subsequent calls not triggering the runtime. Plus the error catcher section wasn't actually suppressing errors, only storing copies while still printing them.

Solution

Color hex codes: 2 new expressions, hex code of %colors% and colour from hex code %strings%. Support for to/from hex strings was added to Color/ColorRGB.

Converting bases: 2 new functions, toBase(value, base) and fromBase(value, base). These use Integer.parseInt() and toString() to convert between bases. the base parameter is ranged from 2 to 36.

Ranged function parameters: Adds a new Modifier, Modifier.RANGED. You can use Modifier.ranged(min, max) to set an inclusive range for a parameter with any Comparable type. If the inputs are literals, Skript will check them against the range and issue parse errors if they're outside:
image

The ranges are also shown in the docs:
image

Runtime errors: Spun simplification into a helper function, wrapped in a RuntimeErrorCatcher, and prints Skript.error() if it catches any. Actually removes all consumers in removeAllConsumers (whoops!).

Testing Completed

Added tests for color expressions and base functions.

Supporting Information


Completes: none
Related: none
AI assistance: none

@sovdeeth sovdeeth requested review from a team and Efnilite as code owners December 7, 2025 06:40
@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Dec 7, 2025
@sovdeeth sovdeeth requested review from cheeezburga and removed request for a team December 7, 2025 06:40
@sovdeeth sovdeeth added the feature Pull request adding a new feature. label Dec 7, 2025
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Dec 7, 2025
@sovdeeth sovdeeth moved this to In Review in 2.14 Releases Dec 7, 2025
@sovdeeth
Copy link
Member Author

sovdeeth commented Dec 7, 2025

Test failure is due to odd interaction between runtime error and simplification
I'll add a fourth PR to this to allow turning runtime errors during simplification into parsing errors via a runtime error consumer tomorrow.

@sovdeeth sovdeeth requested a review from a team as a code owner December 8, 2025 02:21
@sovdeeth sovdeeth requested review from APickledWalrus and removed request for a team December 8, 2025 02:21
@sovdeeth sovdeeth requested a review from Efnilite December 10, 2025 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature. needs reviews A PR that needs additional reviews

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants