-
Notifications
You must be signed in to change notification settings - Fork 263
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
[Bug]: Values set by token.setProperty() in GraalVM are of a different type than values set in MTScript #5152
Comments
It's not a typing issue, it's that Adding a From your Discord message you're just attempting to reset the property to its default, which should have a |
Thanks for looking into this!
I think the paradigm you've set up in #4900 makes sense to expand into
This would be good as well, but while this is my current use case I can foresee issues still arising when generally setting a value that happens to be the default - using Temp HP as an example again, would happen commonly when damaging a creature and removing all of its Temp HP. |
I'm not a fan of raw vs non-raw either, but that's because I don't like the behaviour of resetting a property if the value you set it to is the same as the default. It means you've got to evaluate the default expression every time you set a property and you might intentionally want a value to be set to a value that happens to be the default but conceptually isn't. e.g. If I have a Hero token type that has Strength 10, and I have a given token with Strength 10 because they started with 10, were cursed for a -1 and have a magic sword that gives +1 I would like that to still be 10 after I decide that late on in the campaign new heroes need a buff and I change the token type to have default Strength 12. I would prefer that resetting to default were an explicit step, there is a macro function to do it and I could add a JavaScript function.
This way you could implement resetting to default however you like, without evaluating the content. However this is a pipe dream if every time you open the token editor and save it's going to evaluate the default and remove the value if it's the same as the default. Since that is a much wider change that'd have compatibility issues I suppose I'll settle for:
|
Okay, now that I've actually had time to look at it, it's the Token Editor dialog that's different here. Setting values by name in impersonation scope sets the value. The MTScript It's only the edit dialog that resets token property values if they equal their default. maptool/src/main/java/net/rptools/maptool/client/ui/token/dialog/edit/EditTokenDialog.java Lines 2193 to 2202 in b02a6a5
Seems we were both wrong about how it works. Checking back through the logs it's always been the case that macros set the values directly and you need to use |
Describe the Bug
When using token.setProperty() in GraalVM JS, the value set is somehow not equivalent to the same value being set in MTScript - I suspect due to variable typing. This causes issues when using
getRawProperty()
and likely related functions, as default values are no longer recognized as such. Opening the edit token dialog and clicking "OK" without editing any of the values reverts to expected behavior, likely because the properties are being actually updated into strings.See this discord post if more context is needed.
To Reproduce
a5e.stat.TempHP
with default value of0
will be used.[h:js.eval("let ParentToken = MapTool.tokens.getTokenByID(args[0]); ParentToken.setProperty('a5e.stat.TempHP',0);",getImpersonated())]
[r:getRawProperty("a5e.stat.TempHP",getImpersonated())]
. This will return0
instead of a blank string, which would be expected for a value at its default.[r:getRawProperty("a5e.stat.TempHP",getImpersonated())]
again. This will now correctly return a blank string.Expected Behaviour
Values set by token.setProperty() are able to be recognized as set to the default value in MTScript.
Screenshots
No response
MapTool Info
1.15.2, 1.16.0-beta 4
Desktop
Windows 7
Additional Context
No response
The text was updated successfully, but these errors were encountered: