Projekt:Calliope/Scripte/3
Version vom 4. Juni 2019, 21:59 Uhr von Unhb-owner (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „ let Counter = 0 input.onButtonPressed(Button.B, () => { radio.sendValue("changeValue", 2) Counter += -1 }) input.onButtonPressed(Button.A, () => {…“)
let Counter = 0 input.onButtonPressed(Button.B, () => { radio.sendValue("changeValue", 2) Counter += -1 }) input.onButtonPressed(Button.A, () => { radio.sendValue("changeValue", 1) Counter += 1 }) radio.onDataPacketReceived( ({ receivedString: name, receivedNumber: value }) => { if ("currentValue" == name) { Counter = value } if ("changeValue" == name) { if (value == 1) { Counter += 1 } if (value == 2) { Counter += -1 } } if ("getValue" == name) { radio.sendValue("currentValue", Counter) } }) input.onButtonPressed(Button.AB, () => { radio.sendValue("currentValue", Counter) }) radio.setGroup(17) radio.sendValue("getValue", 1) basic.forever(() => { basic.showNumber(Counter) })