kopia lustrzana https://github.com/backface/turtlestitch
new experimental "When I receive message" hat block
featuring an upvar for the transmission, hidden in dev modesnap7
rodzic
1ba8716f32
commit
0e4a9280b5
|
@ -10,6 +10,7 @@
|
||||||
* user defined custom block palettes
|
* user defined custom block palettes
|
||||||
* PWA, thanks, Joan and John, for pioneering this at Robolot and in Mircoblocks!
|
* PWA, thanks, Joan and John, for pioneering this at Robolot and in Mircoblocks!
|
||||||
* new "blocksZoom=n" url parameter, thanks, Bernat!
|
* new "blocksZoom=n" url parameter, thanks, Bernat!
|
||||||
|
* new "When I receive message" hat block featuring an upvar for the transmission, experimental in dev mode
|
||||||
* **Notable Changes:**
|
* **Notable Changes:**
|
||||||
* saved projects remember the last edited sprite
|
* saved projects remember the last edited sprite
|
||||||
* libraries no longer rely on the JSF primitive, project may need to re-import their libraries to run without having to enable JS extensions
|
* libraries no longer rely on the JSF primitive, project may need to re-import their libraries to run without having to enable JS extensions
|
||||||
|
@ -32,6 +33,9 @@
|
||||||
* German
|
* German
|
||||||
* Chinese, thanks, Simon!
|
* Chinese, thanks, Simon!
|
||||||
|
|
||||||
|
### 2021-09-28
|
||||||
|
* objects, blocks, threads: new "When I receive message" hat block featuring an upvar for the transmission, experimental in dev mode
|
||||||
|
|
||||||
### 2021-09-27
|
### 2021-09-27
|
||||||
* objects: renamed scene event hat block
|
* objects: renamed scene event hat block
|
||||||
* German translation update
|
* German translation update
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
<script src="src/morphic.js?version=2021-07-09"></script>
|
<script src="src/morphic.js?version=2021-07-09"></script>
|
||||||
<script src="src/symbols.js?version=2021-03-03"></script>
|
<script src="src/symbols.js?version=2021-03-03"></script>
|
||||||
<script src="src/widgets.js?version=2021-07-21"></script>
|
<script src="src/widgets.js?version=2021-07-21"></script>
|
||||||
<script src="src/blocks.js?version=2021-09-08"></script>
|
<script src="src/blocks.js?version=2021-09-28"></script>
|
||||||
<script src="src/threads.js?version=2021-09-08"></script>
|
<script src="src/threads.js?version=2021-09-28"></script>
|
||||||
<script src="src/objects.js?version=2021-09-27"></script>
|
<script src="src/objects.js?version=2021-09-28"></script>
|
||||||
<script src="src/scenes.js?version=2021-07-21"></script>
|
<script src="src/scenes.js?version=2021-07-21"></script>
|
||||||
<script src="src/gui.js?version=2021-09-07"></script>
|
<script src="src/gui.js?version=2021-09-07"></script>
|
||||||
<script src="src/paint.js?version=2021-07-05"></script>
|
<script src="src/paint.js?version=2021-07-05"></script>
|
||||||
|
|
|
@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.blocks = '2021-September-08';
|
modules.blocks = '2021-September-28';
|
||||||
|
|
||||||
var SyntaxElementMorph;
|
var SyntaxElementMorph;
|
||||||
var BlockMorph;
|
var BlockMorph;
|
||||||
|
@ -959,6 +959,10 @@ SyntaxElementMorph.prototype.labelParts = {
|
||||||
type: 'template',
|
type: 'template',
|
||||||
label: 'a'
|
label: 'a'
|
||||||
},
|
},
|
||||||
|
'%transmission': { // experimental v7
|
||||||
|
type: 'template',
|
||||||
|
label: 'message'
|
||||||
|
},
|
||||||
'%upvar': {
|
'%upvar': {
|
||||||
type: 'template',
|
type: 'template',
|
||||||
label: '\u2191' // up-arrow
|
label: '\u2191' // up-arrow
|
||||||
|
@ -1629,7 +1633,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'template':
|
case 'template':
|
||||||
part = new TemplateSlotMorph(info.label);
|
part = new TemplateSlotMorph(localize(info.label));
|
||||||
break;
|
break;
|
||||||
case 'color':
|
case 'color':
|
||||||
part = new ColorSlotMorph();
|
part = new ColorSlotMorph();
|
||||||
|
|
|
@ -86,7 +86,7 @@ AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
||||||
|
|
||||||
/*jshint esversion: 6*/
|
/*jshint esversion: 6*/
|
||||||
|
|
||||||
modules.objects = '2021-September-27';
|
modules.objects = '2021-September-28';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -743,6 +743,12 @@ SpriteMorph.prototype.initBlocks = function () {
|
||||||
category: 'control',
|
category: 'control',
|
||||||
spec: 'when I receive %msgHat'
|
spec: 'when I receive %msgHat'
|
||||||
},
|
},
|
||||||
|
receiveTransmission: { // experimental v7
|
||||||
|
dev: true,
|
||||||
|
type: 'hat',
|
||||||
|
category: 'control',
|
||||||
|
spec: 'when I receive %transmission'
|
||||||
|
},
|
||||||
receiveCondition: {
|
receiveCondition: {
|
||||||
type: 'hat',
|
type: 'hat',
|
||||||
category: 'control',
|
category: 'control',
|
||||||
|
@ -2557,6 +2563,14 @@ SpriteMorph.prototype.blockTemplates = function (category = 'motion') {
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
blocks.push(block('doPauseAll'));
|
blocks.push(block('doPauseAll'));
|
||||||
|
|
||||||
|
// for debugging: ///////////////
|
||||||
|
if (devMode) {
|
||||||
|
blocks.push('-');
|
||||||
|
blocks.push(this.devModeText());
|
||||||
|
blocks.push('-');
|
||||||
|
blocks.push(block('receiveTransmission'));
|
||||||
|
}
|
||||||
|
|
||||||
} else if (category === 'sensing') {
|
} else if (category === 'sensing') {
|
||||||
|
|
||||||
blocks.push(block('reportTouchingObject'));
|
blocks.push(block('reportTouchingObject'));
|
||||||
|
@ -6083,22 +6097,29 @@ SpriteMorph.prototype.allSendersOf = function (message, receiverName, known) {
|
||||||
SpriteMorph.prototype.allHatBlocksFor = function (message) {
|
SpriteMorph.prototype.allHatBlocksFor = function (message) {
|
||||||
if (typeof message === 'number') { message = message.toString(); }
|
if (typeof message === 'number') { message = message.toString(); }
|
||||||
return this.scripts.children.filter(morph => {
|
return this.scripts.children.filter(morph => {
|
||||||
var event;
|
var sel = morph.selector,
|
||||||
if (morph.selector) {
|
event;
|
||||||
if (morph.selector === 'receiveMessage') {
|
if (sel) {
|
||||||
|
if (sel === 'receiveMessage') {
|
||||||
event = morph.inputs()[0].evaluate();
|
event = morph.inputs()[0].evaluate();
|
||||||
return event === message
|
return event === message
|
||||||
|| (event instanceof Array
|
|| (event instanceof Array
|
||||||
&& message !== '__shout__go__'
|
&& message !== '__shout__go__'
|
||||||
&& message !== '__clone__init__');
|
&& message !== '__clone__init__'
|
||||||
|
&& message !== '__scene__init__');
|
||||||
}
|
}
|
||||||
if (morph.selector === 'receiveGo') {
|
if (sel === 'receiveTransmission') {
|
||||||
|
return message !== '__shout__go__'
|
||||||
|
&& message !== '__clone__init__'
|
||||||
|
&& message !== '__scene__init__';
|
||||||
|
}
|
||||||
|
if (sel === 'receiveGo') {
|
||||||
return message === '__shout__go__';
|
return message === '__shout__go__';
|
||||||
}
|
}
|
||||||
if (morph.selector === 'receiveOnClone') {
|
if (sel === 'receiveOnClone') {
|
||||||
return message === '__clone__init__';
|
return message === '__clone__init__';
|
||||||
}
|
}
|
||||||
if (morph.selector === 'receiveOnScene') {
|
if (sel === 'receiveOnScene') {
|
||||||
return message === '__scene__init__';
|
return message === '__scene__init__';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8725,11 +8746,11 @@ StageMorph.prototype.blockTemplates = function (category = 'motion') {
|
||||||
blocks.push(block('receiveCondition'));
|
blocks.push(block('receiveCondition'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
blocks.push(block('receiveMessage'));
|
blocks.push(block('receiveMessage'));
|
||||||
|
blocks.push(watcherToggle('getLastMessage'));
|
||||||
|
blocks.push(block('getLastMessage'));
|
||||||
blocks.push(block('doBroadcast'));
|
blocks.push(block('doBroadcast'));
|
||||||
blocks.push(block('doBroadcastAndWait'));
|
blocks.push(block('doBroadcastAndWait'));
|
||||||
blocks.push(block('doSend'));
|
blocks.push(block('doSend'));
|
||||||
blocks.push(watcherToggle('getLastMessage'));
|
|
||||||
blocks.push(block('getLastMessage'));
|
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
blocks.push(block('doWarp'));
|
blocks.push(block('doWarp'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
@ -8766,6 +8787,14 @@ StageMorph.prototype.blockTemplates = function (category = 'motion') {
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
blocks.push(block('doPauseAll'));
|
blocks.push(block('doPauseAll'));
|
||||||
|
|
||||||
|
// for debugging: ///////////////
|
||||||
|
if (this.world().isDevMode) {
|
||||||
|
blocks.push('-');
|
||||||
|
blocks.push(this.devModeText());
|
||||||
|
blocks.push('-');
|
||||||
|
blocks.push(block('receiveTransmission'));
|
||||||
|
}
|
||||||
|
|
||||||
} else if (category === 'sensing') {
|
} else if (category === 'sensing') {
|
||||||
|
|
||||||
blocks.push(block('doAsk'));
|
blocks.push(block('doAsk'));
|
||||||
|
|
|
@ -64,7 +64,7 @@ SnapExtensions, AlignmentMorph, TextMorph, Cloud*/
|
||||||
|
|
||||||
/*jshint esversion: 6*/
|
/*jshint esversion: 6*/
|
||||||
|
|
||||||
modules.threads = '2021-September-08';
|
modules.threads = '2021-September-28';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
@ -3729,13 +3729,33 @@ Process.prototype.doBroadcast = function (message) {
|
||||||
if (msg !== '') {
|
if (msg !== '') {
|
||||||
stage.lastMessage = message; // the actual data structure
|
stage.lastMessage = message; // the actual data structure
|
||||||
rcvrs.forEach(morph => {
|
rcvrs.forEach(morph => {
|
||||||
|
var varFrame;
|
||||||
if (isSnapObject(morph)) {
|
if (isSnapObject(morph)) {
|
||||||
morph.allHatBlocksFor(msg).forEach(block => {
|
morph.allHatBlocksFor(msg).forEach(block => {
|
||||||
procs.push(stage.threads.startProcess(
|
if (block.selector === 'receiveTransmission') {
|
||||||
block,
|
varFrame = new VariableFrame();
|
||||||
morph,
|
varFrame.addVar(
|
||||||
stage.isThreadSafe
|
block.inputs()[0].evaluate(),
|
||||||
));
|
message
|
||||||
|
);
|
||||||
|
procs.push(stage.threads.startProcess(
|
||||||
|
block,
|
||||||
|
morph,
|
||||||
|
stage.isThreadSafe,
|
||||||
|
null, // exportResult (bool)
|
||||||
|
null, // callback
|
||||||
|
null, // isClicked
|
||||||
|
null, // rightAway
|
||||||
|
null, // atomic
|
||||||
|
varFrame
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
procs.push(stage.threads.startProcess(
|
||||||
|
block,
|
||||||
|
morph,
|
||||||
|
stage.isThreadSafe
|
||||||
|
));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Ładowanie…
Reference in New Issue