leopard-js / leopard

Library for making Scratch-like projects with JavaScript.
https://leopardjs.com
MIT License
138 stars 26 forks source link

Broadcast/receive not working? #164

Closed sfederici closed 1 year ago

sfederici commented 1 year ago

In codesandbox https://y5drtp.csb.app/ (original project https://scratch.mit.edu/projects/652422094/editor/) when I click the sprite "Spiegazione1" (brown button) apparently the event is not triggered. Indeed the sprite should hide and the message "spiegazione" should allow the proejct to go on. The same happens if I try to click the sprite "Spiegazione2".

Even in codesandbox https://xvdwl0.csb.app/ (original project https://scratch.mit.edu/projects/807603336/) it seems that a message is not correctly sent/received. To make the project work as expected, I had to add a wait and a hide at line 56 of Sprite1.js as the method whenIReceiveUgh doesn't seem to be triggered.

towerofnix commented 1 year ago

This isn't an issue with broadcast/receive — the project makes use of lots of other broadcasts (powering the animation) which all seem to work correctly. It looks like the "when this sprite clicked" block in the button sprites isn't being triggered.

@PullJosh, we spotted the cause for this bug in https://github.com/leopard-js/leopard/pull/146#discussion_r1127804928 - I'm going to make a patch pull request and release which fixes this bug in the current non-TypeScript codebase, since it's pretty major (and trivial to fix). Would you be able to release that version to the Vercel app site?

(Edit: It turns out to be not quite as trivial, lol. Working on a fix in TypeScript right now since it's still broken there - I should be able to bring it over to the JS end as a patch once we get it working.)

towerofnix commented 1 year ago

@PullJosh Okay, I've pushed a fix and put 1.5.1 up for release! I'm not sure if GitHub actions are run automatically when push is from me, but otherwise it should be good to go for a patch push-to-Vercel. Thank you!

PullJosh commented 1 year ago

@towerofnix The Github action runs when a new release is created. After you push, create a new release using the web UI and then the action will run. (I've done it this time)

Thanks for the fix! :)

Edit: Oh, by the way, the website only needs updating when sb-edit changes. Changes to Leopard don't require the website to behave any differently.

towerofnix commented 1 year ago

Got it, thanks! Sounds good. I guess the site doesn't actually access Leopard (just having generated projects pull from unpkg), so that makes sense.