summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-02-03 17:11:46 +0100
committerjmoenig <jens@moenig.org>2014-02-03 17:11:46 +0100
commit3fede790e437df776366789626b96bfd07f3cefa (patch)
tree9b0ff01cd5da6099dfa18d2fc77962c09a2d0449
parent9d63d129a68713a092a39c37025f896ec4edf00f (diff)
downloadsnap-3fede790e437df776366789626b96bfd07f3cefa.tar.gz
snap-3fede790e437df776366789626b96bfd07f3cefa.zip
Fixed #313
“Block OF sprite” now works for interpolated (“timed”) blocks and for reporters (i.e. SAY FOR, THINK FOR, GLIDE, ASK etc.)
-rwxr-xr-xhistory.txt4
-rw-r--r--threads.js35
2 files changed, 24 insertions, 15 deletions
diff --git a/history.txt b/history.txt
index d2ffc1d..8ff5a12 100755
--- a/history.txt
+++ b/history.txt
@@ -2070,3 +2070,7 @@ ______
* Threads: Revert pull request #295 (xhr-headers), breaks existing installations
* BYOB: Fixed #292 (pulldowns loose lines when exported as library)
* BYOB: Fixed #291 (readonly custom menus become non-readonly when block is edited)
+
+140203
+------
+* Threads: Fixed #313. “Block of sprite” now works for interpolated (“timed”) blocks and for reporters (i.e. SAY FOR, THINK FOR, GLIDE, ASK etc.)
diff --git a/threads.js b/threads.js
index d4a6732..93931c1 100644
--- a/threads.js
+++ b/threads.js
@@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
// Global stuff ////////////////////////////////////////////////////////
-modules.threads = '2014-January-10';
+modules.threads = '2014-Feb-03';
var ThreadManager;
var Process;
@@ -1643,15 +1643,15 @@ Process.prototype.doGlide = function (secs, endX, endY) {
if (!this.context.startTime) {
this.context.startTime = Date.now();
this.context.startValue = new Point(
- this.homeContext.receiver.xPosition(),
- this.homeContext.receiver.yPosition()
+ this.blockReceiver().xPosition(),
+ this.blockReceiver().yPosition()
);
}
if ((Date.now() - this.context.startTime) >= (secs * 1000)) {
- this.homeContext.receiver.gotoXY(endX, endY);
+ this.blockReceiver().gotoXY(endX, endY);
return null;
}
- this.homeContext.receiver.glide(
+ this.blockReceiver().glide(
secs * 1000,
endX,
endY,
@@ -1666,10 +1666,10 @@ Process.prototype.doGlide = function (secs, endX, endY) {
Process.prototype.doSayFor = function (data, secs) {
if (!this.context.startTime) {
this.context.startTime = Date.now();
- this.homeContext.receiver.bubble(data);
+ this.blockReceiver().bubble(data);
}
if ((Date.now() - this.context.startTime) >= (secs * 1000)) {
- this.homeContext.receiver.stopTalking();
+ this.blockReceiver().stopTalking();
return null;
}
this.pushContext('doYield');
@@ -1679,16 +1679,21 @@ Process.prototype.doSayFor = function (data, secs) {
Process.prototype.doThinkFor = function (data, secs) {
if (!this.context.startTime) {
this.context.startTime = Date.now();
- this.homeContext.receiver.doThink(data);
+ this.blockReceiver().doThink(data);
}
if ((Date.now() - this.context.startTime) >= (secs * 1000)) {
- this.homeContext.receiver.stopTalking();
+ this.blockReceiver().stopTalking();
return null;
}
this.pushContext('doYield');
this.pushContext();
};
+Process.prototype.blockReceiver = function () {
+ return this.context ? this.context.receiver || this.homeContext.receiver
+ : this.homeContext.receiver;
+};
+
// Process sound primitives (interpolated)
Process.prototype.doPlaySoundUntilDone = function (name) {
@@ -1723,7 +1728,7 @@ Process.prototype.doStopAllSounds = function () {
Process.prototype.doAsk = function (data) {
var stage = this.homeContext.receiver.parentThatIsA(StageMorph),
- isStage = this.homeContext.receiver instanceof StageMorph,
+ isStage = this.blockReceiver() instanceof StageMorph,
activePrompter;
if (!this.prompter) {
@@ -1733,7 +1738,7 @@ Process.prototype.doAsk = function (data) {
);
if (!activePrompter) {
if (!isStage) {
- this.homeContext.receiver.bubble(data, false, true);
+ this.blockReceiver().bubble(data, false, true);
}
this.prompter = new StagePrompterMorph(isStage ? data : null);
if (stage.scale < 1) {
@@ -1753,7 +1758,7 @@ Process.prototype.doAsk = function (data) {
stage.lastAnswer = this.prompter.inputField.getValue();
this.prompter.destroy();
this.prompter = null;
- if (!isStage) {this.homeContext.receiver.stopTalking(); }
+ if (!isStage) {this.blockReceiver().stopTalking(); }
return null;
}
}
@@ -2288,7 +2293,7 @@ Process.prototype.createClone = function (name) {
// Process sensing primitives
Process.prototype.reportTouchingObject = function (name) {
- var thisObj = this.homeContext.receiver;
+ var thisObj = this.blockReceiver();
if (thisObj) {
return this.objectTouchingObject(thisObj, name);
@@ -2384,7 +2389,7 @@ Process.prototype.reportColorIsTouchingColor = function (color1, color2) {
};
Process.prototype.reportDistanceTo = function (name) {
- var thisObj = this.homeContext.receiver,
+ var thisObj = this.blockReceiver(),
thatObj,
stage,
rc,
@@ -2407,7 +2412,7 @@ Process.prototype.reportDistanceTo = function (name) {
};
Process.prototype.reportAttributeOf = function (attribute, name) {
- var thisObj = this.homeContext.receiver,
+ var thisObj = this.blockReceiver(),
thatObj,
stage;