Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #381
Issue
The issue was triggered by my intention to reorganize and write the WPScript API documentation. While reviewing the code, I noticed that some interfaces were not documented in the existing API documentation. Upon attempting to use them, I discovered the following bugs.
This pull request addresses two bugs in the WorldPainter script:
CreateFilterOp.onlyOnLayer(layer).withValue(value)
andCreateFilterOp.exceptOnLayer(layer).withValue(value)
are opposite to the expected behavior:orHigher()
/orLower()
methods ofCreateFilterOp
are always unusable:The JavaScript code that caused the error is as follows:
In the original source code, to ensure that
orHigher()
andorLower()
are not set simultaneously, the following condition was made:However, in practice, the constructor of
LayerValue
always initializesonlyOn.condition
andexceptOn.condition
toDefaultFilter.Condition.EQUAL
. Therefore, the truth value of the condition(LayerValue) onlyOn).condition != null
is always true.Fix
Modified the modifyStrength() method of ExceptOnTerrainOrLayerFilter and OnlyOnTerrainOrLayerFilter to address the issue of filter operation return values.
Modify the judgment criteria of the orHigher() and orLower() methods to check whether they are set simultaneously based on whether the original value is QUAL or null.
Testing
The JavaScript script for testing is as follows( Assuming the existence of `TestLayer'):
by the way
I am currently attempting to rewrite the WPScriptAPI documentation, filling in the gaps left by the old documentation, including sections on how to initialize UI parameters in scripts. Since English is not my first language, this might take some time, but once I'm finished, I'll promptly submit this documentation to the repository. I would greatly appreciate it if you could help review the content.
Additionally, I'm also trying to add some interesting controls to the UI parameters feature of WPScript, including combox and sliders, among others. However, these are still a work in progress. If I complete them, would you be open to incorporating these changes?
