Skip to content

Conversation

@sovdeeth
Copy link
Member

Description

Adds an api for declaring custom default values during parsing. Does not apply to runtime defaults like arithmetic.
The goal of this is to provide a slightly easier method for section to provide section-specific defaults without having to create an entire custom event and change the context.

I think this implementation might be a little rough and would welcome critiques.

Example:

		// Add custom default value
		data.addDefaultValue(Number.class, new SimpleLiteral((Number) 7, true));

		// parse section with custom value
		loadCode(sectionNode);

		// remove custom value
		data.removeDefaultValue(Number.class);

Target Minecraft Versions: any
Requirements: none
Related Issues: none

@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Dec 12, 2024
@sovdeeth
Copy link
Member Author

sovdeeth commented Dec 12, 2024

Just realized this needs to support multiple layers of default values. Will fix Friday.

default value A:
  default B:
    # default is B
  # default should be A

@sovdeeth
Copy link
Member Author

I would like some thoughts on how/whether to handle cases where context completely changes.
Perhaps a clearDefaults() and restoreDefaults() method? Maybe defaults should be tied to event/a context generic?
not sure, would like suggestions

@sovdeeth sovdeeth requested review from a team as code owners April 24, 2025 15:43
@sovdeeth sovdeeth requested review from APickledWalrus and Pesekjak and removed request for a team April 24, 2025 15:43
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label May 15, 2025
@sovdeeth sovdeeth moved this to In Progress in 2.12 Releases Jun 3, 2025
@sovdeeth sovdeeth moved this from In Progress to Needs Reviews in 2.12 Releases Jun 3, 2025
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

This looks pretty good. Just have a few comments I'd like discussion on before merging

@skriptlang-automation skriptlang-automation bot removed the needs reviews A PR that needs additional reviews label Jun 5, 2025
@sovdeeth sovdeeth requested a review from APickledWalrus June 29, 2025 23:13
@github-project-automation github-project-automation bot moved this from In Review to Awaiting Merge in 2.12 Releases Jun 30, 2025
@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 Jun 30, 2025
@sovdeeth sovdeeth merged commit b815974 into SkriptLang:dev/feature Jun 30, 2025
5 checks passed
@skriptlang-automation skriptlang-automation bot added the completed The issue has been fully resolved and the change will be in the next Skript update. label Jun 30, 2025
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done in 2.12 Releases Jun 30, 2025
@skriptlang-automation skriptlang-automation bot removed the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label Jun 30, 2025
Burbulinis pushed a commit to Burbulinis/Skript that referenced this pull request Jul 9, 2025
* add custom default value api

* handle nested custom defaults

* requested changes

* requested changes

---------

Co-authored-by: Moderocky <admin@moderocky.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

completed The issue has been fully resolved and the change will be in the next Skript update. enhancement Feature request, an issue about something that could be improved, or a PR improving something.

Projects

Status: Done - Released

Development

Successfully merging this pull request may close these issues.

3 participants