Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some syntaxes overwriting variable list indices and add new helper method for changing expressions. #7120

Merged
merged 8 commits into from
Nov 23, 2024

Conversation

sovdeeth
Copy link
Member

@sovdeeth sovdeeth commented Sep 30, 2024

Description

A few expressions/effects currently clear the indices of variable lists used in them, since they use ChangeMode#SET indiscriminately. This PR adds a new default method on Expression, changeInPlace(Event, Function), which applies a Function to each value of the Expression, then calls change() with SET using the new values.
For Variables, this method is overwritten to use the variable's iterator, meaning that calling expr.changeInPlace() is a safe way to change all expressions while maintaining indices for variable lists.

Behavior change is limited to not overwriting variable indices anymore, but also it does not remove elements of the wrong type from variable lists:

	set {_test::1} to vector(0,3,0)
	set {_test::a} to vector(0,0,4)
	set {_test::hello world} to "abc"
	set vector length of {_test::*} to 1
	# {_test::*} still contains "abc" now

I believe this to be bug fixing rather than breaking, but let me know if you disagree.
or if you disagree with the implementation!


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

@sovdeeth sovdeeth added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something. labels Sep 30, 2024
@sovdeeth sovdeeth added the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label Nov 6, 2024
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.

Great work! It is nice to see this problem fixed.

@sovdeeth sovdeeth merged commit 49b2a37 into SkriptLang:dev/patch Nov 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something. patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants