ast+js: Compile sensing_of

This commit is contained in:
Thomas Weber committed 2020-09-17 18:32:11 -05:00
1 parent 70cde0847c
commit 5ec294a517
3 files changed
+8 -1

No files matched your search

+6
View File
@@ -614,6 +614,12 @@ class ScriptTreeGenerator {
kind: 'constant',
value: block.fields.OBJECT.value
};
case 'sensing_of':
return {
kind: 'sensing.of',
property: block.fields.PROPERTY.value,
object: this.descendInput(block, 'OBJECT')
};
case 'sensing_timer':
return {
kind: 'timer.get'
-1
View File
@@ -50,7 +50,6 @@ const inputs = [
'sensing_current',
'sensing_loud',
'sensing_loudness',
'sensing_of',
'sound_volume',
'translate_getTranslate',
'translate_getViewerLanguage',
+2
View File
@@ -471,6 +471,8 @@ class JSGenerator {
case 'sensing.distance':
// TODO: on stages, this can be computed at compile time
return new TypedInput(`distance(${this.descendInput(node.target).asString()})`, TYPE_NUMBER);
case 'sensing.of':
return new TypedInput(`runtime.ext_scratch3_sensing.getAttributeOf({OBJECT: ${this.descendInput(node.object).asString()}, PROPERTY: "${sanitize(node.property)}" })`, TYPE_UNKNOWN);
case 'sensing.touching':
return new TypedInput(`target.isTouchingObject(${this.descendInput(node.object).asUnknown()})`, TYPE_BOOLEAN);
case 'sensing.touchingColor':