-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Summary
Possibly Wrong Handling if decompiler.Blocks.value(value)
where value is float
and will be Converted to Integer
Example
Test Project: Bouncing Ball Example Project by griffpatch_tutor
Generated GS code: generated/Ball.gs
Diff from expected: YuevUwU@fdd2fe5
What's Wrong
All floats are converted to integers. Consequently, the 0.98 gravity becomes ZERO.🤣
Although there is a backdrop scaling issue (960x720 in the source should be scaled to 480x360), this "may" be solvable by tweaking the resolution of image (untested). This is not the main issue I want to mention.
Expect
If there are no obstacles for Scratch 3, the float values should be kept as original value.
Also, it's not ruled out that is expected for GS.
Environment
goboscript: aspizu/goboscript@894987c
goboscript.ide: aspizu/goboscript.ide@0fd4862 (latest deploy hasn't resolve negative parsing error)
sb2gs: 47c813d
Related Code
Lines 143 to 156 in 47c813d
def value(self, value: float | str): | |
try: | |
value = int(value) | |
except ValueError: | |
with contextlib.suppress(ValueError): | |
if value in ("Infinity", "-Infinity"): | |
raise ValueError from None | |
value = float(value) | |
match value: | |
case int() | float(): | |
self.write(str(value)) | |
case str(): | |
self.str(value) |
My simple scene will work with this patch, but I'm concerned about edge cases.
try:
- value = int(value)
+ if isinstance(value, str):
+ value = int(value)
I didn't fully understand the internals of Scratch and JavaScript yet and goboscript is also under active development, so feel free to find the best solution the author thinks or fix only when dev or somebody are passionate about.
I leave some my findings for the author's reference. (shit code warning)
Regardless of whether this issue is resolved, thank aspizu for filling my dream in my private and blank repository before🛐