mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 10:39:56 -05:00
Add a limit to the number of items a list can have. No-op on 'addToList' block if trying to add to a list that is already at the limit.
This commit is contained in:
parent
6c0d257a63
commit
b436b5fd82
1 changed files with 9 additions and 1 deletions
|
@ -74,7 +74,7 @@ class Scratch3DataBlocks {
|
|||
addToList (args, util) {
|
||||
const list = util.target.lookupOrCreateList(
|
||||
args.LIST.id, args.LIST.name);
|
||||
list.value.push(args.ITEM);
|
||||
if (list.value.length < Scratch3DataBlocks.LIST_ITEM_LIMIT) list.value.push(args.ITEM);
|
||||
}
|
||||
|
||||
deleteOfList (args, util) {
|
||||
|
@ -144,6 +144,14 @@ class Scratch3DataBlocks {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type representation for list variables.
|
||||
* @const {string}
|
||||
*/
|
||||
static get LIST_ITEM_LIMIT () {
|
||||
return 200000;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Scratch3DataBlocks;
|
||||
|
|
Loading…
Reference in a new issue