Merge pull request #1327 from thisandagain/feature/deleteall

Add opcode implementation for `data_deletealloflist`
This commit is contained in:
Andrew Sliwinski 2018-07-12 11:02:14 -04:00 committed by GitHub
commit 0c21f739ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ class Scratch3DataBlocks {
data_listcontents: this.getListContents, data_listcontents: this.getListContents,
data_addtolist: this.addToList, data_addtolist: this.addToList,
data_deleteoflist: this.deleteOfList, data_deleteoflist: this.deleteOfList,
data_deletealloflist: this.deleteAllOfList,
data_insertatlist: this.insertAtList, data_insertatlist: this.insertAtList,
data_replaceitemoflist: this.replaceItemOfList, data_replaceitemoflist: this.replaceItemOfList,
data_itemoflist: this.getItemOfList, data_itemoflist: this.getItemOfList,
@ -136,6 +137,13 @@ class Scratch3DataBlocks {
list._monitorUpToDate = false; list._monitorUpToDate = false;
} }
deleteAllOfList (args, util) {
const list = util.target.lookupOrCreateList(
args.LIST.id, args.LIST.name);
list.value = [];
return;
}
insertAtList (args, util) { insertAtList (args, util) {
const item = args.ITEM; const item = args.ITEM;
const list = util.target.lookupOrCreateList( const list = util.target.lookupOrCreateList(