Skript icon indicating copy to clipboard operation
Skript copied to clipboard

API for custom default values during parsing.

Open sovdeeth opened this issue 1 year ago • 2 comments

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 avatar Dec 12 '24 02:12 sovdeeth

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 avatar Dec 12 '24 02:12 sovdeeth

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 avatar Dec 13 '24 05:12 sovdeeth