kopia lustrzana https://github.com/backface/turtlestitch
rodzic
10e09ec3f2
commit
a0cbf2993c
|
@ -3531,6 +3531,7 @@ Fixes:
|
|||
170712
|
||||
------
|
||||
* Blocks: fixed #1800. Thanks, Ken, for the bug report!
|
||||
* Objects, Threads: “new clone of ...” primitive, made TELL, ASK primitives official
|
||||
|
||||
|
||||
|
||||
|
|
58
objects.js
58
objects.js
|
@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
|
|||
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/
|
||||
|
||||
modules.objects = '2017-July-11';
|
||||
modules.objects = '2017-July-12';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -753,6 +753,11 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
category: 'control',
|
||||
spec: 'create a clone of %cln'
|
||||
},
|
||||
newClone: {
|
||||
type: 'reporter',
|
||||
category: 'control',
|
||||
spec: 'a new clone of %cln'
|
||||
},
|
||||
removeClone: {
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
|
@ -1992,23 +1997,13 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push('-');
|
||||
blocks.push(block('receiveOnClone'));
|
||||
blocks.push(block('createClone'));
|
||||
blocks.push(block('newClone'));
|
||||
blocks.push(block('removeClone'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doPauseAll'));
|
||||
|
||||
// for debugging: ///////////////
|
||||
if (this.world().isDevMode) {
|
||||
blocks.push('-');
|
||||
txt = new TextMorph(localize(
|
||||
'development mode \ndebugging primitives:'
|
||||
));
|
||||
txt.fontSize = 9;
|
||||
txt.setColor(this.paletteTextColor);
|
||||
blocks.push(txt);
|
||||
blocks.push('-');
|
||||
blocks.push(block('doTellTo'));
|
||||
blocks.push(block('reportAskFor'));
|
||||
}
|
||||
blocks.push('-');
|
||||
blocks.push(block('doTellTo'));
|
||||
blocks.push(block('reportAskFor'));
|
||||
|
||||
} else if (cat === 'sensing') {
|
||||
|
||||
|
@ -3221,10 +3216,21 @@ SpriteMorph.prototype.remove = function () {
|
|||
*/
|
||||
|
||||
SpriteMorph.prototype.createClone = function (immediately) {
|
||||
var stage = this.parentThatIsA(StageMorph);
|
||||
var stage = this.parentThatIsA(StageMorph),
|
||||
clone;
|
||||
if (stage && stage.cloneCount <= 5000) {
|
||||
this.fullCopy(true).clonify(stage, immediately);
|
||||
clone = this.fullCopy(true);
|
||||
clone.clonify(stage, immediately);
|
||||
}
|
||||
return clone;
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.newClone = function (immediately) {
|
||||
var clone = this.createClone(immediately);
|
||||
if (isNil(clone)) {
|
||||
throw new Error('exceeding maximum number of clones');
|
||||
}
|
||||
return clone;
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.clonify = function (stage, immediately) {
|
||||
|
@ -6904,22 +6910,12 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('reportCallCC'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('createClone'));
|
||||
blocks.push(block('newClone'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doPauseAll'));
|
||||
|
||||
// for debugging: ///////////////
|
||||
if (this.world().isDevMode) {
|
||||
blocks.push('-');
|
||||
txt = new TextMorph(localize(
|
||||
'development mode \ndebugging primitives:'
|
||||
));
|
||||
txt.fontSize = 9;
|
||||
txt.setColor(this.paletteTextColor);
|
||||
blocks.push(txt);
|
||||
blocks.push('-');
|
||||
blocks.push(block('doTellTo'));
|
||||
blocks.push(block('reportAskFor'));
|
||||
}
|
||||
blocks.push('-');
|
||||
blocks.push(block('doTellTo'));
|
||||
blocks.push(block('reportAskFor'));
|
||||
|
||||
} else if (cat === 'sensing') {
|
||||
|
||||
|
|
18
threads.js
18
threads.js
|
@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
|
|||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
||||
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
||||
|
||||
modules.threads = '2017-July-09';
|
||||
modules.threads = '2017-July-12';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -2813,6 +2813,22 @@ Process.prototype.createClone = function (name) {
|
|||
}
|
||||
};
|
||||
|
||||
Process.prototype.newClone = function (name) {
|
||||
var thisObj = this.blockReceiver(),
|
||||
thatObj;
|
||||
|
||||
if (!name) {return; }
|
||||
if (thisObj) {
|
||||
if (this.inputOption(name) === 'myself') {
|
||||
return thisObj.newClone(!this.isFirstStep);
|
||||
}
|
||||
thatObj = this.getOtherObject(name, thisObj);
|
||||
if (thatObj) {
|
||||
return thatObj.newClone(!this.isFirstStep);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Process sensing primitives
|
||||
|
||||
Process.prototype.reportTouchingObject = function (name) {
|
||||
|
|
Ładowanie…
Reference in New Issue