mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-08 20:14:00 -04:00
Finishing up lists.
This commit is contained in:
parent
b18938963f
commit
038a65b460
4 changed files with 51 additions and 19 deletions
src/serialization
|
@ -234,7 +234,7 @@ const parseScratchObject = function (object, runtime, extensions, topLevel) {
|
|||
const newVariable = new Variable(
|
||||
getVariableId(variable.name),
|
||||
variable.name,
|
||||
"",
|
||||
'',
|
||||
variable.isPersistent
|
||||
);
|
||||
newVariable.value = variable.value;
|
||||
|
@ -254,7 +254,7 @@ const parseScratchObject = function (object, runtime, extensions, topLevel) {
|
|||
const newVariable = new Variable(
|
||||
getVariableId(list.listName),
|
||||
list.listName,
|
||||
"list",
|
||||
'list',
|
||||
list.isPersistent
|
||||
);
|
||||
newVariable.value = list.contents;
|
||||
|
@ -490,10 +490,14 @@ const parseBlock = function (sb2block, getVariableId, extensions) {
|
|||
value: providedArg
|
||||
};
|
||||
|
||||
if (expectedArg.fieldName === 'VARIABLE') {
|
||||
if (expectedArg.fieldName === 'VARIABLE' || expectedArg.fieldName === 'LIST') {
|
||||
// Add `id` property to variable fields
|
||||
activeBlock.fields[expectedArg.fieldName].id = getVariableId(providedArg);
|
||||
}
|
||||
const varType = expectedArg.variableType;
|
||||
if (typeof varType === 'string') {
|
||||
activeBlock.fields[expectedArg.fieldName].variableType = varType;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Special cases to generate mutations.
|
||||
|
|
|
@ -1201,7 +1201,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'VARIABLE'
|
||||
fieldName: 'VARIABLE',
|
||||
variableType: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1210,7 +1211,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'VARIABLE'
|
||||
fieldName: 'VARIABLE',
|
||||
variableType: ''
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
|
@ -1224,7 +1226,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'VARIABLE'
|
||||
fieldName: 'VARIABLE',
|
||||
variableType: ''
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
|
@ -1238,7 +1241,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'VARIABLE'
|
||||
fieldName: 'VARIABLE',
|
||||
variableType: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1247,7 +1251,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'VARIABLE'
|
||||
fieldName: 'VARIABLE',
|
||||
variableType: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1256,7 +1261,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1270,7 +1276,8 @@ const specMap = {
|
|||
},
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1284,7 +1291,8 @@ const specMap = {
|
|||
},
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1303,7 +1311,8 @@ const specMap = {
|
|||
},
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1317,7 +1326,8 @@ const specMap = {
|
|||
},
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
|
@ -1336,7 +1346,8 @@ const specMap = {
|
|||
},
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1345,7 +1356,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1354,7 +1366,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
|
@ -1368,7 +1381,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1377,7 +1391,8 @@ const specMap = {
|
|||
argMap: [
|
||||
{
|
||||
type: 'field',
|
||||
fieldName: 'LIST'
|
||||
fieldName: 'LIST',
|
||||
variableType: 'list'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue