File size: 823 Bytes
30c32c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//THIS IS A TEST EXTENSION, AND AT NO POINT SHOULD IT BE ADDED TO THE EXTENSION MENU OR THE IMPORT LIST

class TESTEXTENSION {
  getInfo() {
    return {
      id: 'TESTEXTENSION', // change this if you make an actual extension!
      name: 'TESTEXTENSION',
      blocks: [
        {
          opcode: 'logBranch',
          blockType: Scratch.BlockType.COMMAND,
          branchCount: 1,
          text: 'Log value of first block in branch',
        }
      ]
    };
  }
  logBranch(args, util) {
    if (util.thread.peekStack() && util.target.blocks.getBlock(util.thread.peekStack()) && util.target.blocks.getBlock(util.thread.peekStack()).inputs.SUBSTACK.block) {
      console.log(util.target.blocks.getBlock(util.thread.peekStack()).inputs.SUBSTACK.block)
    }
  }
}
Scratch.extensions.register(new TESTEXTENSION());