File tree Expand file tree Collapse file tree 4 files changed +41
-4
lines changed Expand file tree Collapse file tree 4 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -1429,12 +1429,11 @@ class Runtime extends EventEmitter {
1429
1429
break ;
1430
1430
}
1431
1431
1432
- // Check if "blockShape" is specified
1432
+ // Allow extensiosn to override outputShape
1433
1433
if ( blockInfo . blockShape ) {
1434
- blockJSON . outputShape = blockInfo . outputShape || ScratchBlocksConstants . OUTPUT_SHAPE_ROUND ;
1434
+ blockJSON . outputShape = blockInfo . blockShape ;
1435
1435
}
1436
1436
1437
-
1438
1437
const blockText = Array . isArray ( blockInfo . text ) ? blockInfo . text : [ blockInfo . text ] ;
1439
1438
let inTextNum = 0 ; // text for the next block "arm" is blockText[inTextNum]
1440
1439
let inBranchNum = 0 ; // how many branches have we placed into the JSON so far?
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
const ArgumentType = require ( './argument-type' ) ;
2
2
const BlockType = require ( './block-type' ) ;
3
- const BlockShape = require ( './block-shape' ) ;
3
+ const BlockShape = require ( './tw- block-shape' ) ;
4
4
const TargetType = require ( './target-type' ) ;
5
5
const Cast = require ( '../util/cast' ) ;
6
6
Original file line number Diff line number Diff line change
1
+ const { test} = require ( 'tap' ) ;
2
+ const Runtime = require ( '../../src/engine/runtime' ) ;
3
+ const Scratch = require ( '../../src/extension-support/tw-extension-api-common' ) ;
4
+
5
+ test ( 'blockShape' , t => {
6
+ const rt = new Runtime ( ) ;
7
+ rt . _registerExtensionPrimitives ( {
8
+ id : 'shapetest' ,
9
+ name : 'shapetest' ,
10
+ blocks : [
11
+ {
12
+ blockType : Scratch . BlockType . REPORTER ,
13
+ blockShape : Scratch . BlockShape . HEXAGONAL ,
14
+ opcode : 'hexagonal' ,
15
+ text : 'hexagonal'
16
+ } ,
17
+ {
18
+ blockType : Scratch . BlockType . BOOLEAN ,
19
+ blockShape : Scratch . BlockShape . ROUND ,
20
+ opcode : 'round' ,
21
+ text : 'round'
22
+ } ,
23
+ {
24
+ blockType : Scratch . BlockType . REPORTER ,
25
+ blockShape : Scratch . BlockShape . SQUARE ,
26
+ opcode : 'square' ,
27
+ text : 'square'
28
+ }
29
+ ]
30
+ } ) ;
31
+
32
+ const json = rt . getBlocksJSON ( ) ;
33
+ t . equal ( json . length , 3 ) ;
34
+ t . equal ( json [ 0 ] . outputShape , 1 ) ;
35
+ t . equal ( json [ 1 ] . outputShape , 2 ) ;
36
+ t . equal ( json [ 2 ] . outputShape , 3 ) ;
37
+ t . end ( ) ;
38
+ } ) ;
You can’t perform that action at this time.
0 commit comments