Comment by svieira
3 months ago
> So the other trick is the Easel compiler assigns an implicit ID to things like sprites so that it will replace rather than add the second time around
Is the ID computed based on the shape of the expression at runtime or on something else?
I found https://easel.games/docs/learn/language/functions/ids#implic... which suggests they are structure-based, at least, though loops aren't mentioned.
Great documentation, by the by!
The implicit ID is just an auto-incremented number actually, it's not anything too special. That means, if you have a loop, the component has the same ID each time and gets replaced. That is a feature, not a bug. So this code snippet will keep replacing the text sprite with a new one, counting from 1 to 10:
for i in RangeInclusive(1, 10) { TextSprite(i) }
Yes, you found the right place in the documentation. Thanks, yes I worked very hard on the documentation!
Ah, so you don't do parallel with implicit IDs right now, I'm guessing. Or you do, but it has some interesting bugs as the IDs shift around? Or the scope of the auto-incrementing number is lower than "the entire program" so parallel works?
3 replies →