Map and clean deprecated functions (#175)
* add image and deprecated arrow functions * update locales * map basic.showArrow * map arrow blocks * map & remove arrow images * remove arrow blocks * update locales * remove & patch: rgbw -> rgb button/pin pressed -> button/pin event loudness -> soundLevel * update ts mappings for arrows * add wip ts patch rules * update .blocks files * use Click instead of Down as default in Documentation and tests * patch test.blocks * fix lowercase name tag * update test.blocks * update blocks test files * update blocks test files * format block files * pass blocks file tests * fix ts mapping * fix color.defl value closes https://github.com/microsoft/pxt-calliope/issues/136 * fix ts mappings - add optional spacing at the end of rgbw() - map up to v4.0.19 * add suggested changes * replace innerText by textContent Co-authored-by: JW <gitkraken@juriwolf.de> Co-authored-by: Juri <info@juriwolf.de>
This commit is contained in:
		@@ -11,7 +11,7 @@ Let's create a coin flipping program to simulate a real coin toss. We'll use ico
 | 
			
		||||
Get an ``||input:on button A pressed||`` block from the ``||input:Input||`` drawer in the toolbox. We'll put our coin flipping code in here.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -22,7 +22,7 @@ Grab an ``||logic:if else||`` block and set it inside ``||input:on button A pres
 | 
			
		||||
The ``||Math:pick random true or false||`` returns a random ``true`` or ``false`` value which we use to determine a ``heads`` or ``tails`` result for a coin toss.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
 | 
			
		||||
    if (Math.randomBoolean()) {
 | 
			
		||||
    } else {
 | 
			
		||||
    }
 | 
			
		||||
@@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => {
 | 
			
		||||
Now, put a ``||basic:show icon||`` block inside both the ``||logic:if||`` and the ``||logic:else||``. Pick images to mean ``heads`` and ``tails``.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
 | 
			
		||||
    if (Math.randomBoolean()) {
 | 
			
		||||
        basic.showIcon(IconNames.Skull)
 | 
			
		||||
    } else {
 | 
			
		||||
@@ -52,7 +52,7 @@ Press button **A** in the simulator to try the coin toss code.
 | 
			
		||||
You can animate the coin toss to add the feeling of suspense. Place different ``||basic:show icon||`` blocks before the ``||logic:if||`` to show that the coin is flipping.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
 | 
			
		||||
    basic.showIcon(IconNames.Diamond)
 | 
			
		||||
    basic.showIcon(IconNames.SmallDiamond)
 | 
			
		||||
    basic.showIcon(IconNames.Diamond)
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ Make a love meter, how sweet! The @boardname@ is feeling the love, then sometime
 | 
			
		||||
Let's build a **LOVE METER** machine. Place an ``||input:on pin pressed||`` block to run code when pin **0** is pressed. Use ``P0`` from the list of pin inputs.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onPinPressed(TouchPin.P0, () => {
 | 
			
		||||
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => {
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -20,7 +20,7 @@ input.onPinPressed(TouchPin.P0, () => {
 | 
			
		||||
Using ``||basic:show number||`` and ``||Math:pick random||`` blocks, show a random number from `0` to `100` when pin **0** is pressed.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onPinPressed(TouchPin.P0, () => {
 | 
			
		||||
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => {
 | 
			
		||||
    basic.showNumber(randint(0, 100));
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
@@ -34,7 +34,7 @@ Show ``"LOVE METER"`` on the screen when the @boardname@ starts.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
basic.showString("LOVE METER");
 | 
			
		||||
input.onPinPressed(TouchPin.P0, () => {
 | 
			
		||||
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Down, () => {
 | 
			
		||||
    basic.showNumber(randint(0, 100));
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ Use ``||input:on button pressed||`` to send a text message over radio with ``||r
 | 
			
		||||
Every @boardname@ nearby will receive this message.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
 | 
			
		||||
    radio.sendString("Yo");
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
@@ -41,7 +41,7 @@ radio.onReceivedString(function (receivedString) {
 | 
			
		||||
Press button **A** on the simulator, you will notice that a second @boardname@ appears (if your screen is too small, the simulator might decide not to show it). Try pressing **A** again and notice that the "Yo" message gets displayed on the other @boardname@.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
 | 
			
		||||
    radio.sendString("Yo");
 | 
			
		||||
});
 | 
			
		||||
radio.onReceivedString(function (receivedString) {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ First, let's get your name to display on the screen.
 | 
			
		||||
From the ``||input:Input||`` Toolbox drawer, drag an ``||input:on button A pressed||`` block onto the Workspace.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
 | 
			
		||||
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
@@ -23,7 +23,7 @@ input.onButtonPressed(Button.A, function () {
 | 
			
		||||
From the ``||basic:Basic||`` Toolbox drawer drag a ``||basic:show string||`` block into the ``||input:on button A pressed||`` block.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
 | 
			
		||||
    basic.showString("Hello!")
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
@@ -33,7 +33,7 @@ input.onButtonPressed(Button.A, function () {
 | 
			
		||||
In the ``||basic:show string||`` block, type your name.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
 | 
			
		||||
    basic.showString("My Name")
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
@@ -43,7 +43,7 @@ input.onButtonPressed(Button.A, function () {
 | 
			
		||||
Go to the simulator and test your name badge by pressing button **A**.
 | 
			
		||||
 | 
			
		||||
```sim
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
 | 
			
		||||
    basic.showString("My Name")
 | 
			
		||||
})
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -123,7 +123,7 @@ basic.forever(function () {
 | 
			
		||||
**MakeCode blocks for the Robot Unicorn controller**
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.AB, function () {
 | 
			
		||||
input.onButtonEvent(Button.AB, ButtonEvent.Down, function () {
 | 
			
		||||
    radio.sendNumber(4)
 | 
			
		||||
    basic.showLeds(`
 | 
			
		||||
        # . . . #
 | 
			
		||||
 
 | 
			
		||||
@@ -83,7 +83,7 @@ Now that we are detecting pulses, we can use a variable to count them too. In th
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let pulseCount = 0
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Down, function () {
 | 
			
		||||
    basic.showNumber(pulseCount)
 | 
			
		||||
    pulseCount = 0
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ Code the buttons on the @boardname@ to show that it's happy or sad.
 | 
			
		||||
Place a ``||input:on button pressed||`` block to run code when button **A** is pressed.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => { 
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -21,7 +21,7 @@ input.onButtonPressed(Button.A, () => {
 | 
			
		||||
Place a ``||basic:show leds||`` block inside ``||input:on button pressed||`` to display a smiley on the screen. Press the **A** button in the simulator to see the smiley.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.A, () => { 
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => { 
 | 
			
		||||
    basic.showLeds(`
 | 
			
		||||
        # # . # #
 | 
			
		||||
        # # . # #
 | 
			
		||||
@@ -37,7 +37,7 @@ input.onButtonPressed(Button.A, () => {
 | 
			
		||||
Add ``||input:on button pressed||`` and ``||basic:show leds||`` blocks to display a frowny when button **B** is pressed.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.B, () => { 
 | 
			
		||||
input.onButtonEvent(Button.B, ButtonEvent.Click, () => { 
 | 
			
		||||
    basic.showLeds(`
 | 
			
		||||
        # # . # #
 | 
			
		||||
        # # . # #
 | 
			
		||||
@@ -53,7 +53,7 @@ input.onButtonPressed(Button.B, () => {
 | 
			
		||||
Add a secret mode that happens when **A** and **B** are pressed together. For this case, add multiple ``||basic:show leds||`` blocks to create an animation.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
input.onButtonPressed(Button.AB, () => {
 | 
			
		||||
input.onButtonEvent(Button.AB, ButtonEvent.Click, () => {
 | 
			
		||||
    basic.showLeds(`
 | 
			
		||||
        . . . . .
 | 
			
		||||
        # . # . .
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ Use a ``||input:on button pressed||`` block to handle the **A** button. Put in a
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite = game.createSprite(2, 2)
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
 | 
			
		||||
    if (sprite.get(LedSpriteProperty.X) == 2) {
 | 
			
		||||
    } else {
 | 
			
		||||
    }
 | 
			
		||||
@@ -77,7 +77,7 @@ Finally, pull out an ``||game:add score||`` and a ``||game:game over||`` block t
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite = game.createSprite(2, 2)
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
 | 
			
		||||
    if (sprite.get(LedSpriteProperty.X) == 2) {
 | 
			
		||||
        game.addScore(1)
 | 
			
		||||
    } else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user