kopia lustrzana https://github.com/backface/turtlestitch
added experimental “tell ... to ..." and “ask ... for ...” primitives
(hidden in dev mode)upd4.1
rodzic
b6159d7b19
commit
2133f1a8f0
|
@ -3514,6 +3514,12 @@ Fixes:
|
|||
170708
|
||||
------
|
||||
* Threads: Assert data types to list operations -> meaningful error messages
|
||||
* GUI: enable inheritance per default, must be user-enabled for existing projects
|
||||
|
||||
170709
|
||||
------
|
||||
* Objects, Threads: added experimental (hidden in dev mode) “tell ... to ..." and “ask ... for ...” primitives
|
||||
|
||||
|
||||
|
||||
Features:
|
||||
|
|
50
objects.js
50
objects.js
|
@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
|
|||
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/
|
||||
|
||||
modules.objects = '2017-July-07';
|
||||
modules.objects = '2017-July-09';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -726,7 +726,23 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
spec: 'warp %c'
|
||||
},
|
||||
|
||||
// Cloning - very experimental
|
||||
// Message passing - very experimental
|
||||
|
||||
doTellTo: {
|
||||
dev: true,
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
spec: 'tell %spr to %cl'
|
||||
},
|
||||
reportAskFor: {
|
||||
dev: true,
|
||||
type: 'reporter',
|
||||
category: 'control',
|
||||
spec: 'ask %spr for %repRing'
|
||||
},
|
||||
|
||||
// Cloning
|
||||
|
||||
receiveOnClone: {
|
||||
type: 'hat',
|
||||
category: 'control',
|
||||
|
@ -856,7 +872,7 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
reportAttributeOf: {
|
||||
type: 'reporter',
|
||||
category: 'sensing',
|
||||
spec: '%att of %spr',
|
||||
spec: '%att of ',
|
||||
defaults: [['costume #']]
|
||||
},
|
||||
reportURL: {
|
||||
|
@ -1968,6 +1984,20 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
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'));
|
||||
}
|
||||
|
||||
} else if (cat === 'sensing') {
|
||||
|
||||
blocks.push(block('reportTouchingObject'));
|
||||
|
@ -6856,6 +6886,20 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
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'));
|
||||
}
|
||||
|
||||
} else if (cat === 'sensing') {
|
||||
|
||||
blocks.push(block('doAsk'));
|
||||
|
|
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-08';
|
||||
modules.threads = '2017-July-09';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -1620,6 +1620,22 @@ Process.prototype.doDeleteAttr = function (attrName) {
|
|||
}
|
||||
};
|
||||
|
||||
// experimental message passing primitives
|
||||
|
||||
Process.prototype.doTellTo = function (sprite, context) {
|
||||
this.doRun(
|
||||
this.reportAttributeOf(context, sprite),
|
||||
new List()
|
||||
);
|
||||
};
|
||||
|
||||
Process.prototype.reportAskFor = function (sprite, context) {
|
||||
this.evaluate(
|
||||
this.reportAttributeOf(context, sprite),
|
||||
new List()
|
||||
);
|
||||
};
|
||||
|
||||
// Process lists primitives
|
||||
|
||||
Process.prototype.reportNewList = function (elements) {
|
||||
|
|
Ładowanie…
Reference in New Issue