Scratch-vm: Add support for deprecated blocks from 2.0 and 1.4

Created on 17 Dec 2016  路  13Comments  路  Source: LLK/scratch-vm

(Edited by @thisandagain on 12/24/2016)

https://wiki.scratch.mit.edu/wiki/List_of_Obsolete_Blocks

feature help wanted

Most helpful comment

@thisandagain @kchadha I've made PRs for each block in my checklist, which I've also adjusted a bit since I started it a few weeks ago. I think this is all the relevant blocks; it covers all the ones in thisandagain's breakdown image above, as well as all blocks in the scratch-flash source code.* Are any others wanted?

* Okay, this is just technically a lie :) - I haven't implemented drum:duration:elapsed:from: or midiInstrument:. These are being tracked in #861; they'll take a bit more work to implement (because of the "midi number"-scratch instrument mapping). The rest are here, though!

All 13 comments

Umm Arent they trying to get rid of hacked block usage...

Yes, but just letting the blocks disappear (like they do currently), I don't believe is a good option, may be we should convert the hacked blocks into normal blocks (like forever if turned into a if block inside a forever block)

I like that. And counter could be named counter1 or counter2 etc. using the same method they use to resolve collisions with costume names

This will also need to include the old 1.4 style sound and drum blocks

I feel like if they add features that ATers usually have to hack the blocks for that will be key.

I'm going to modify the scope the scope of this to be more clear. We need to make sure we support the deprecated opcodes from 1.X to 2.0:
https://wiki.scratch.mit.edu/wiki/List_of_Obsolete_Blocks

For "hacked" blocks, we will support a more robust extension paradigm in 3.0 to be discussed soon.

See also #1030.

@thisandagain I assume the particular blocks wanted are those titled "Pseudo-Legacy" in the "Opcode Hacking" section of the slideshow? Are there any others? I've noted a couple extras below anyhow.


For reference:

  • [x] doForLoop: PR #963.
  • [x] doWhile: PR #1032. Its behavior is exactly the opposite of doUntil (i.e. "repeat until"): while the condition is true (rather than false), run the contained blocks.
  • [x] warpSpeed ("all at once"): PR #1096. Its behavior is to run the contained blocks as they are (don't actually go into "warp speed", i.e. no-refresh). ("all at once: { move 10 steps, turn 15 degrees }" is functionally equivalent to "move 10 steps, turn 15 degrees".)
  • [x] [Counter blocks](https://github.com/LLK/scratch-flash/blob/9fbac92ef3d09ceca0c0782f8a08deaa79e4df69/src/Specs.as#L378-L381): PR #1033.

    • The counter value is a global value that defaults to zero.

    • counter: Return the counter value.

    • incr counter: Increment the counter's value by one.

    • clear counter: Set the counter value to zero.

  • [x] [Scroll blocks](https://github.com/LLK/scratch-flash/blob/9fbac92ef3d09ceca0c0782f8a08deaa79e4df69/src/Specs.as#L386-L391): PR #1099. These are all no-ops.
  • [x] ["hide all sprites", "user id"](https://github.com/LLK/scratch-flash/blob/9fbac92ef3d09ceca0c0782f8a08deaa79e4df69/src/Specs.as#L393-L395), and those suspicious "setStretchTo" and "changeStretchBy" blocks in @thisandagain's notes below: PR #1102. Also no-ops.
  • [x] ["loud?"](https://github.com/LLK/scratch-flash/blob/96a2a9a7fca2d042da25dc0d4423900163ab4f33/src/Specs.as#L366): PR #1101. Its behavior is to return whether or not the sound level (i.e. result of "loudness") is greater than 10 (so it's identical to loudness > 10).
  • Various 1.4 blocks that should automatically be converted to their 2.0+ forms. (Not a checkbox since this will probably be looked at separately from these blocks.)

    • abs (val) -> ("abs") of (val)

    • sqrt (val) -> ("sqrt") of (val)

    • stop script -> stop ("this script")

    • stop all -> stop ("all")

    • switch to background (bg) -> switch backdrop to (bg)

    • next background -> next backdrop

    • forever if (cond): (script) -> forever: if (cond): (script)

@towerofnix That's a great list. Here is a usage breakdown (all shared projects):

image

We still don't have a 1.4 import / spec-map, but that is something @kchadha will be looking at soon.

@thisandagain @kchadha I've made PRs for each block in my checklist, which I've also adjusted a bit since I started it a few weeks ago. I think this is all the relevant blocks; it covers all the ones in thisandagain's breakdown image above, as well as all blocks in the scratch-flash source code.* Are any others wanted?

* Okay, this is just technically a lie :) - I haven't implemented drum:duration:elapsed:from: or midiInstrument:. These are being tracked in #861; they'll take a bit more work to implement (because of the "midi number"-scratch instrument mapping). The rest are here, though!

@towerofnix Amazing! Thank you so much. @kchadha and I will take a look at these PRs over the coming week.

@towerofnix This is awesome! Thanks for making all of these changes. =D

Glad to help :)

There's just one more block that needs to be added, which I forgot about -- "costume name" (spotted in this project). I intend for that to be automatically converted from "costume name" to "costume (name)" - i.e. the new costume-(name/number) block - the same way "costume #" is converted to "costume (number)".

I'm just not 100% sure on how to go about doing this. Currently the spec mapping for "costume #" looks like this:

'costumeIndex': {
  opcode: 'looks_costumenumbername',
  argMap: [
  ]
}

There's nothing explicitly saying that the argument should be set to "number", so I'm not sure how to go about making it (in costumeName) be set to "name".

Update - Although if this is too complicated, no worries, there can just be a hidden "costume name" block. (I'm not sure how to approach the issue -- there doesn't seem to be anything in the serialization/sb2.js code that would already help tackle this, and I don't think it's worth it to create an entire new parser feature (that obviously would require tests and what-not) for a single obsolete block.)

Along the same lines as "costume name," if the stretch effect from #982 is implemented, should the old "set stretch" blocks to map to those?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CatsAreFluffy picture CatsAreFluffy  路  6Comments

fsih picture fsih  路  7Comments

apple502j picture apple502j  路  6Comments

cwillisf picture cwillisf  路  4Comments

thisandagain picture thisandagain  路  3Comments