diff --git a/HISTORY.md b/HISTORY.md index 263d2818..7a713721 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,7 @@ * parse JSON using the SPLIT reporter * new "aspect AT location" reporter in Sensing category for sniffing colors and sprites * new blocks for setting and changing the stage's background color + * new "object" reporter in the Sensing category for getting a sprite by its name * new "string" library, thanks, Brian * added "neg" selector to monadic function reporter in "Operators" category * enhances support for embedding Snap in other website, thanks, Bernat! @@ -32,6 +33,7 @@ * German ### 2019-01-28 +* Threads, Objects: new "object" reporter in the Sensing category * Greek translation update, thanks, Alexandros! * pushed version to "Beta" diff --git a/snap.html b/snap.html index c10ee63c..8eb17187 100755 --- a/snap.html +++ b/snap.html @@ -7,8 +7,8 @@ - - + + diff --git a/src/objects.js b/src/objects.js index c830dbe2..31e2e86b 100644 --- a/src/objects.js +++ b/src/objects.js @@ -83,7 +83,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize, TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph, AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/ -modules.objects = '2019-January-23'; +modules.objects = '2019-January-28'; var SpriteMorph; var StageMorph; @@ -847,6 +847,11 @@ SpriteMorph.prototype.initBlocks = function () { spec: '%att of %spr', defaults: [['costume #']] }, + reportObject: { + type: 'reporter', + category: 'sensing', + spec: 'object %spr' + }, reportURL: { type: 'reporter', category: 'sensing', @@ -2027,6 +2032,8 @@ SpriteMorph.prototype.blockTemplates = function (category) { if (SpriteMorph.prototype.enableFirstClass) { blocks.push(block('reportGet')); } + + blocks.push(block('reportObject')); blocks.push('-'); blocks.push(block('reportURL')); @@ -7238,6 +7245,8 @@ StageMorph.prototype.blockTemplates = function (category) { if (SpriteMorph.prototype.enableFirstClass) { blocks.push(block('reportGet')); } + + blocks.push(block('reportObject')); blocks.push('-'); blocks.push(block('reportURL')); diff --git a/src/threads.js b/src/threads.js index 6722e38b..c649acb3 100644 --- a/src/threads.js +++ b/src/threads.js @@ -62,7 +62,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, Color, TableFrameMorph, ColorSlotMorph, isSnapObject, Map*/ -modules.threads = '2019-January-25'; +modules.threads = '2019-January-28'; var ThreadManager; var Process; @@ -3584,6 +3584,26 @@ Process.prototype.reportGet = function (query) { return ''; }; +Process.prototype.reportObject = function (name) { + var thisObj = this.blockReceiver(), + thatObj, + stage; + + if (thisObj) { + this.assertAlive(thisObj); + stage = thisObj.parentThatIsA(StageMorph); + if (stage.name === name) { + thatObj = stage; + } else { + thatObj = this.getOtherObject(name, thisObj, stage); + } + if (thatObj) { + this.assertAlive(thatObj); + } + return thatObj; + } +}; + Process.prototype.doSet = function (attribute, value) { // experimental, manipulate sprites' attributes var name, rcvr;