pxt-calliope/docs/reference/control/reset.md
Juri Wolf 77ed2ccfb1
V4 updates (#210)
* update pxt.json files

* Fix button event enums

fixes https://github.com/microsoft/pxt-calliope/issues/206

* Fix Safari CSS Rule for iOS app

fixes https://github.com/microsoft/pxt-calliope/issues/205

* aprove preffered repos

should fix https://github.com/microsoft/pxt-calliope/issues/167
2023-01-11 09:51:27 -08:00

859 B

Reset

Reset the @boardname@ and start the program again.

This function is like pressing the reset button on the back of the @boardname@.

control.reset()

~hint

Simulator

The reset function works only on a real @boardname@ and not in the simulator.

~

Example

This program will count as high as you like when you press button A. When you get tired of counting, press button B to reset the @boardname@ and start the program over.

let item = 0;
basic.showNumber(item);
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => {
    item = item + 1;
    basic.showNumber(item);
});
input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Down), () => {
    control.reset();
});

See also

clear screen, game over