Describe your problem:
Skript dev37c no longer does calculations correctly. Indeed, when we remove a number from a variable that is not set, this value is added to the variable instead.
Code
command test123:
trigger:
remove 7 from {_x}
broadcast "x= %{_x}%" #Result will be 7 and not -7
Debug
__Skript:__ dev37c
__Addons:__ Tested without addons
__Server:__ CraftBukkit version git-Spigot-3d850ec-809c399 (MC: 1.12.2) and Paper version git-TacoSpigot-"f8ba67d6" (MC: 1.12.2)
Can confirm, good find
Don't think it's that rare to do number operations on unset variables like this and issues with calculations can mess up important scripted systems (like an economy).
Removing from variable that does not contain anything should not result in any number. Technically, valid result would be NaN... But in case of Skript, I think doing nothing would be most intuitive.
@bensku honestly I think it might be not the best idea to change this, I've seen many scripts that just do for instance:
loop something:
if something of loop-something is something:
add 1 to {_count}
without ever setting the {_count} to 0 anywhere, I think many users consider it a feature
Absolutely confirming what @Nicofisi just said there. Not only do i use that, i've seen many people do it
That's for addition though I've never seen someone doing the same for removal. In my opinion, doing nothing when it comes to removal makes sense however, we'd need to discuss whether it would be reasonable for the user or be misleading due to how addition works already.
I think since it's used a lot for addition, it should also work for removal/subtraction even if it's not used a lot. Consistency is important. I agree that I use this and have seen others use it as well.
I know this would be a breaking change. The issue I have with old behavior is that it causes hidden type conversions. As Javascript shows, those can cause all sorts of fun bugs. Still, point taken - not good idea to change this in some random development release just before adding 1.13 support.
Most helpful comment
I think since it's used a lot for addition, it should also work for removal/subtraction even if it's not used a lot. Consistency is important. I agree that I use this and have seen others use it as well.