Skript icon indicating copy to clipboard operation
Skript copied to clipboard

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

Open sovdeeth opened this issue 4 months ago • 0 comments

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 avatar Sep 30 '24 18:09 sovdeeth