mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-03 17:50:28 -04:00
Changing parsing of custom procedures for new style
This commit is contained in:
parent
e4830dfe51
commit
b0870518a4
4 changed files with 31 additions and 11 deletions
src/serialization
|
@ -481,14 +481,31 @@ const parseBlock = function (sb2block, getVariableId) {
|
|||
// Mutation for procedure definition:
|
||||
// store all 2.0 proc data.
|
||||
const procData = sb2block.slice(1);
|
||||
activeBlock.mutation = {
|
||||
tagName: 'mutation',
|
||||
proccode: procData[0], // e.g., "abc %n %b %s"
|
||||
argumentnames: JSON.stringify(procData[1]), // e.g. ['arg1', 'arg2']
|
||||
argumentdefaults: JSON.stringify(procData[2]), // e.g., [1, 'abc']
|
||||
warp: procData[3], // Warp mode, e.g., true/false.
|
||||
children: []
|
||||
// Create a new block and input metadata.
|
||||
const inputUid = uid();
|
||||
const inputName = 'custom_block';
|
||||
activeBlock.inputs[inputName] = {
|
||||
name: inputName,
|
||||
block: inputUid,
|
||||
shadow: inputUid
|
||||
};
|
||||
activeBlock.children = [{
|
||||
id: inputUid,
|
||||
opcode: 'procedures_callnoreturn_internal',
|
||||
inputs: {},
|
||||
fields: {},
|
||||
next: null,
|
||||
shadow: true,
|
||||
children: [],
|
||||
mutation: {
|
||||
tagName: 'mutation',
|
||||
proccode: procData[0], // e.g., "abc %n %b %s"
|
||||
argumentnames: JSON.stringify(procData[1]), // e.g. ['arg1', 'arg2']
|
||||
argumentdefaults: JSON.stringify(procData[2]), // e.g., [1, 'abc']
|
||||
warp: procData[3], // Warp mode, e.g., true/false.
|
||||
children: []
|
||||
}
|
||||
}];
|
||||
} else if (oldOpcode === 'call') {
|
||||
// Mutation for procedure call:
|
||||
// string for proc code (e.g., "abc %n %b %s").
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue