as the title says. i made a for element value of (array of sprites of type) loop, then, in that loop i have a block setting a newly made variable with no other uses to “value”. Makecode gave me an error saying “type sprite is not assignable to type number”. the error does not happen if i were to set the variable to something like “get first value from (array of sprites of type)”, even though that should be the same value.
fairly sure this is new. i swear ive done this in other projects and not gotten a bug.
2 Likes
I hast been summoned, send me thy holy link
1 Like
This is an issue with how blocks are translated to javaScript internally. I don’t know how simple of a fix this could be on the Makecode Dev side, (@richard is this just something that isn’t being checked when making variable definitions?) but I can say that doing something else to tell Makecode that the variable is indeed a sprite will usually solve this issue, for example doing something like this:
This just jabs Makecode a bit to remind it that “var” is supposed to be a sprite. Essentially the issue is that Makecode isn’t looking at “value” to define what “var” is, so it doesn’t know “var” is a sprite.
1 Like
I made a small test program to demonstrate the issue.
although it seems @WoofWoof beat me to it.
1 Like
What I do is make a separate variable that is defined as a sprite, set “var” to that variable so it knows it is a sprite, go on with regular code, then destroy the sprite that helped define “var”.
1 Like