added a %self menu

pull/89/head
jmoenig 2019-05-08 09:41:31 +02:00
rodzic 6a65fa7c9c
commit 03acf231cd
4 zmienionych plików z 23 dodań i 4 usunięć

Wyświetl plik

@ -79,6 +79,7 @@
### 2019-05-08 ### 2019-05-08
* Blocks, Objects, Threads: integrated video capture control into global settings prims in Sensing * Blocks, Objects, Threads: integrated video capture control into global settings prims in Sensing
* Blocks, Threads: added a %self menu
### 2019-05-07 ### 2019-05-07
* Blocks, Objects, Threads, Video: optimized video motion detection * Blocks, Objects, Threads, Video: optimized video motion detection

Wyświetl plik

@ -1165,6 +1165,14 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
true true
); );
break; break;
case '%self':
part = new InputSlotMorph(
null,
false,
'objectsMenuWithSelf',
true
);
break;
case '%col': // collision detection case '%col': // collision detection
part = new InputSlotMorph( part = new InputSlotMorph(
null, null,
@ -8889,12 +8897,19 @@ InputSlotMorph.prototype.clonablesMenu = function () {
return dict; return dict;
}; };
InputSlotMorph.prototype.objectsMenu = function () { InputSlotMorph.prototype.objectsMenuWithSelf = function () {
return this.objectsMenu(true);
};
InputSlotMorph.prototype.objectsMenu = function (includeMyself) {
var rcvr = this.parentThatIsA(BlockMorph).scriptTarget(), var rcvr = this.parentThatIsA(BlockMorph).scriptTarget(),
stage = rcvr.parentThatIsA(StageMorph), stage = rcvr.parentThatIsA(StageMorph),
dict = {}, dict = {},
allNames = []; allNames = [];
if (includeMyself) {
dict.myself = ['myself'];
}
dict[stage.name] = stage.name; dict[stage.name] = stage.name;
stage.children.forEach(function (morph) { stage.children.forEach(function (morph) {
if (morph instanceof SpriteMorph && !morph.isTemporary) { if (morph instanceof SpriteMorph && !morph.isTemporary) {

Wyświetl plik

@ -960,7 +960,8 @@ SpriteMorph.prototype.initBlocks = function () {
reportObject: { reportObject: {
type: 'reporter', type: 'reporter',
category: 'sensing', category: 'sensing',
spec: 'object %spr' spec: 'object %self',
defaults: [['myself']]
}, },
reportURL: { reportURL: {
type: 'reporter', type: 'reporter',

Wyświetl plik

@ -3418,15 +3418,17 @@ Process.prototype.getOtherObject = function (name, thisObj, stageObj) {
// private, find the sprite indicated by the given name // private, find the sprite indicated by the given name
// either onstage or in the World's hand // either onstage or in the World's hand
// experimental: deal with first-class sprites // deal with first-class sprites
if (isSnapObject(name)) { if (isSnapObject(name)) {
return name; return name;
} }
if (this.inputOption(name) === 'myself') {
return thisObj;
}
var stage = isNil(stageObj) ? var stage = isNil(stageObj) ?
thisObj.parentThatIsA(StageMorph) : stageObj, thisObj.parentThatIsA(StageMorph) : stageObj,
thatObj = null; thatObj = null;
if (stage) { if (stage) {
// find the corresponding sprite on the stage // find the corresponding sprite on the stage
thatObj = detect( thatObj = detect(