Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code runs on the selected sprite, instead of the sprite where the script is located #2885

Closed
thomaswp opened this issue Oct 13, 2020 · 2 comments

Comments

@thomaswp
Copy link

Issue: When running code in Netsblox, the sprite currently selected in the corral will do all actions (e.g. move, say, etc.), rather than the sprite where the script is, which should be doing these actions.

For example, if I have two sprites:

Sprite 1 (gray) with the following code:
myRole script pic (1)

and Sprite 2 (orange) with no code...

If I have Sprite 2 selected, and click the green flag, I see this:
image

Sprite 2 has said hello, instead of Sprite 1, where the script is.

I've uploaded the test code here (change to .xml):
test.xml.txt

When I first encountered this error, it was with some older code I had loaded, and I got a javascript error (I can't reproduce it). The error was something like: cannot find target for script. Which make sense, since the issue is that the wrong script target is being used.

@thomaswp
Copy link
Author

I was able to reproduce the error I noticed before:

If I open the Air Quality example, open the Stage sprite and hit the green flag, I get this:

image

Here's the trace:

editor.netsblox.org/:1 Autofocus processing was blocked because a document already has a focused element.
app.min.js?v=1.20.3:2234 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
IDE_Morph.getURL @ app.min.js?v=1.20.3:2234
app.min.js?v=1.20.3:2926 received "openProject" event 0: Object
app.min.js?v=1.20.3:954 Uncaught (in promise) Error: script target cannot be found for orphaned scripts
    at ScriptsMorph.scriptTarget (app.min.js?v=1.20.3:954)
    at HatBlockMorph.BlockMorph.scriptTarget (app.min.js?v=1.20.3:766)
    at new Process (app.min.js?v=1.20.3:1212)
    at ThreadManager.startProcess (app.min.js?v=1.20.3:1202)
    at app.min.js?v=1.20.3:1712
    at Array.forEach (<anonymous>)
    at app.min.js?v=1.20.3:1712
    at Array.forEach (<anonymous>)
    at StageMorph.fireGreenFlagEvent (app.min.js?v=1.20.3:1712)
    at NetsBloxMorph.IDE_Morph.runScripts (app.min.js?v=1.20.3:2066)
app.min.js?v=1.20.3:954 Uncaught Error: script target cannot be found for orphaned scripts
    at ScriptsMorph.scriptTarget (app.min.js?v=1.20.3:954)
    at HatBlockMorph.BlockMorph.scriptTarget (app.min.js?v=1.20.3:766)
    at new Process (app.min.js?v=1.20.3:1212)
    at ThreadManager.startProcess (app.min.js?v=1.20.3:1202)
    at app.min.js?v=1.20.3:1712
    at Array.forEach (<anonymous>)
    at app.min.js?v=1.20.3:1712
    at Array.forEach (<anonymous>)
    at StageMorph.fireGreenFlagEvent (app.min.js?v=1.20.3:1712)
    at NetsBloxMorph.IDE_Morph.runScripts (app.min.js?v=1.20.3:2066)
app.min.js?v=1.20.3:954 Uncaught Error: script target cannot be found for orphaned scripts
    at ScriptsMorph.scriptTarget (app.min.js?v=1.20.3:954)
    at HatBlockMorph.BlockMorph.scriptTarget (app.min.js?v=1.20.3:766)
    at new Process (app.min.js?v=1.20.3:1212)
    at ThreadManager.startProcess (app.min.js?v=1.20.3:1202)
    at app.min.js?v=1.20.3:1712
    at Array.forEach (<anonymous>)
    at app.min.js?v=1.20.3:1712
    at Array.forEach (<anonymous>)
    at StageMorph.fireGreenFlagEvent (app.min.js?v=1.20.3:1712)
    at NetsBloxMorph.IDE_Morph.runScripts (app.min.js?v=1.20.3:2066)

@brollb
Copy link
Contributor

brollb commented Oct 13, 2020

Closing this as the problematic code is in the client repo. Updates can be found here: NetsBlox/Snap--Build-Your-Own-Blocks#1105.

@brollb brollb closed this as completed Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants