summaryrefslogtreecommitdiffstats
path: root/examples/sensors/grue/qml_app/main.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sensors/grue/qml_app/main.qml')
-rw-r--r--examples/sensors/grue/qml_app/main.qml16
1 files changed, 7 insertions, 9 deletions
diff --git a/examples/sensors/grue/qml_app/main.qml b/examples/sensors/grue/qml_app/main.qml
index f3ae6ed1..5177b04f 100644
--- a/examples/sensors/grue/qml_app/main.qml
+++ b/examples/sensors/grue/qml_app/main.qml
@@ -50,24 +50,22 @@ Item {
GrueSensor {
id: sensor
active: true
- property int lastPercent: 0
onReadingChanged: {
- var percent = Math.floor(reading.chanceOfBeingEaten * 100);
+ var percent = reading.chanceOfBeingEaten;
var thetext = "";
- if (percent == 0) {
+ if (percent === 0) {
thetext = "It is light. You are safe from Grues.";
- } else if (lastPercent == 0) {
- thetext = "It is dark. You are likely to be eaten by a Grue.";
}
- if (percent == 100) {
- thetext += " You have been eaten by a Grue!";
+ else if (percent === 100) {
+ thetext = "You have been eaten by a Grue!";
sensor.active = false;
- } else if (percent) {
+ }
+ else if (percent > 0) {
+ thetext = "It is dark. You are likely to be eaten by a Grue.";
thetext += " Your chance of being eaten by a Grue: "+percent+" percent.";
}
text.font.pixelSize = 30;
text.text = "<p>" + thetext + "</p>";
- lastPercent = percent;
}
}