diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index e29af19c..0cf93b5a 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -66,7 +66,7 @@ namespace brick { //% hidden _update(curr: boolean) { - if (curr === null) return + if (this == null) return if (this._isPressed == curr) return this._isPressed = curr if (curr) { diff --git a/libs/core/input.ts b/libs/core/input.ts index e67bc1a2..894c8602 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -68,7 +68,7 @@ namespace sensors.internal { if (info.sensor) return info.sensor._query() return 0 }, (prev, curr) => { - if (info.sensor && curr != null) info.sensor._update(prev, curr) + if (info.sensor) info.sensor._update(prev, curr) }) } @@ -214,6 +214,7 @@ namespace sensors.internal { } public setLevel(level: number) { + if (this == null) return this.level = this.clampValue(level); if (this.level >= this.highThreshold) {