You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using tilemaps, MakeCode Arcade has blocks to retrieve an arbitrary tilemap location (tiles.getTileLocation(col,row)) as well as the tilemap Location of a sprite (mySprite.tilemapLocation()). Checking if two Locations are equal (i.e., they correspond to the same location on the TileMap) always returns false.
To Reproduce
Steps to reproduce the behavior:
Create a new MakeCode Arcade project.
Add a Tilemap asset.
Compare tilemap locations. Code:
tiles.setCurrentTileMap(tilemap`level1`)// use whatever the your tilemap is called// compare the same locationconsole.log(tiles.getTileLocation(0,0)==tiles.getTileLocation(0,0))// false// compare the location of a sprite at the same locationletmySprite=sprites.create(img`a a a`,SpriteKind.Player)// use whatever imagetiles.placeOnTile(mySprite,tiles.getTileLocation(3,4))// place the sprite at (3,4) on the tilemapconsole.log(mySprite.tilemapLocation()==tiles.getTileLocation(3,4))// false
Expected behavior
Tilemap locations at the same column and row should return true when compared.
And/or in Blocks mode, a warning or error should come up on the comparison block that Locations (or objects in general) can't be compared with it or the user should not be able to put a Location block into a logic block's open spaces.
Desktop (please complete the following information):
OS: Windows 10 (build 19045)
Browser: Chrome 129 (64-bit)
Additional context
I suppose this is because JavaScript comparisons using == of two objects are based on their references and not their values and two different Location objects would indeed not be the same. As a developer, this would be known, however for those just starting out, and considering that this comparison can be done in the Blocks editor as well, this could be confusing (sidenote: I ran into this issue while using MakeCode Arcade at a summer camp for youth 12-14).
The text was updated successfully, but these errors were encountered:
jernwerber
changed the title
Bug: Two Locations at the same TileMap coordiantes on the same TileMap are not equal
Bug: Two Locations at the same TileMap coordinates on the same TileMap are not equal
Oct 14, 2024
Also, I wouldn't mind taking a crack at addressing this, should it be something that is deemed fix-worthy. I see that strings are already treated as special for comparison, so I don't think it's too big of a stretch to treat objects (or even just some MakeCode objects) as special as well.
When using tilemaps, MakeCode Arcade has blocks to retrieve an arbitrary tilemap location (
tiles.getTileLocation(col,row)
) as well as the tilemap Location of a sprite (mySprite.tilemapLocation()
). Checking if two Locations are equal (i.e., they correspond to the same location on the TileMap) always returnsfalse
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Desktop (please complete the following information):
Additional context
I suppose this is because JavaScript comparisons using
==
of two objects are based on their references and not their values and two different Location objects would indeed not be the same. As a developer, this would be known, however for those just starting out, and considering that this comparison can be done in the Blocks editor as well, this could be confusing (sidenote: I ran into this issue while using MakeCode Arcade at a summer camp for youth 12-14).The text was updated successfully, but these errors were encountered: