mirror of
https://github.com/scratchfoundation/scratch-sb1-converter.git
synced 2025-02-16 03:29:45 -05:00
fix: resolve issues with blocks referencing mouse, edge, and stage
resolves #1 and resolves #31
This commit is contained in:
parent
89ec324122
commit
c537ca618b
1 changed files with 20 additions and 1 deletions
|
@ -3,6 +3,20 @@
|
|||
import {ImageMediaData, SoundMediaData, SpriteData} from '../squeak/types';
|
||||
import md5 from 'js-md5';
|
||||
|
||||
// https://github.com/LLK/scratch-flash/blob/cb5f42f039ef633710faf9c63b69e8368b280372/src/blocks/BlockIO.as#L292-L308
|
||||
const fixMouseEdgeRef = block => {
|
||||
const oldVal = String(block[block.length - 1]);
|
||||
const last = block.length - 1;
|
||||
if (oldVal === 'mouse') {
|
||||
block[last] = '_mouse_';
|
||||
} else if (oldVal === 'edge') {
|
||||
block[last] = '_edge_';
|
||||
} else if (oldVal === 'StageData') {
|
||||
block[last] = '_stage_';
|
||||
}
|
||||
return block;
|
||||
};
|
||||
|
||||
const sb1SpecMap = {
|
||||
// https://github.com/LLK/scratch-flash/blob/cb5f42f039ef633710faf9c63b69e8368b280372/src/blocks/BlockIO.as#L197-L199
|
||||
'getParam': ([a, b, c, d]) => [a, b, c, d || 'r'],
|
||||
|
@ -41,7 +55,12 @@ const sb1SpecMap = {
|
|||
// https://github.com/LLK/scratch-flash/blob/cb5f42f039ef633710faf9c63b69e8368b280372/src/blocks/BlockIO.as#L271-L273
|
||||
'nextBackground': () => ['nextScene'],
|
||||
// https://github.com/LLK/scratch-flash/blob/cb5f42f039ef633710faf9c63b69e8368b280372/src/blocks/BlockIO.as#L274-L282
|
||||
'doForeverIf': block => ['doForever', [['doIf', block[1], block[2]]]]
|
||||
'doForeverIf': block => ['doForever', [['doIf', block[1], block[2]]]],
|
||||
'getAttribute:of:': fixMouseEdgeRef,
|
||||
'gotoSpriteOrMouse:': fixMouseEdgeRef,
|
||||
'distanceTo:': fixMouseEdgeRef,
|
||||
'pointTowards:': fixMouseEdgeRef,
|
||||
'touching:': fixMouseEdgeRef
|
||||
};
|
||||
|
||||
const valueOf = obj => {
|
||||
|
|
Loading…
Reference in a new issue