pxt icon indicating copy to clipboard operation
pxt copied to clipboard

### @diffs doesn't seem to work in tutorials

Open Yngel72 opened this issue 4 years ago • 2 comments

The command "### @diffs true" invariably seems to generate the error message "Unknown command: @diffs" when used as described in the documentation. Starting a document like this, for instance, will generate the error message:

@activities true

@diffs true

scene.setBackgroundColor(9)
let mySprite = sprites.create(img`
    . . . . . . . . . . . . . . . . 
    . . . . . . . . . . . . . . . . 
    . . . . . . . . . b 5 5 b . . . 
    . . . . . . b b b b b b . . . . 
    . . . . . b b 5 5 5 5 5 b . . . 
    . b b b b b 5 5 5 5 5 5 5 b . . 
    . b d 5 b 5 5 5 5 5 5 5 5 b . . 
    . . b 5 5 b 5 d 1 f 5 d 4 f . . 
    . . b d 5 5 b 1 f f 5 4 4 c . . 
    b b d b 5 5 5 d f b 4 4 4 4 b . 
    b d d c d 5 5 b 5 4 4 4 4 4 4 b 
    c d d d c c b 5 5 5 5 5 5 5 b . 
    c b d d d d d 5 5 5 5 5 5 5 b . 
    . c d d d d d d 5 5 5 5 5 d b . 
    . . c b d d d d d 5 5 5 b b . . 
    . . . c c c c c c c c b b . . . 
    `, SpriteKind.Player)
controller.moveSprite(mySprite)# tutorial

So far, I haven't found a working example of @diffs in any code I've browsed through on GitHub.

Using "// @highlight" within the code on the line above the block you need to highlight works as described in the documentation for highighting blocks, but is there a way to highlight variables that's been changed or added within blocks?

Yngel72 avatar Jan 24 '22 08:01 Yngel72

Ah, so I think even with diffs on, it will highlight the entire block and not just the changed variable. But here's an example of the @diffs flag that you can try in the tutorial tool!:

### @activities true
### @diffs true

# My Tutorial

## My Activity

### Step 1

Here is some text.

```blocks 
let mySprite = sprites.create(img`.`, SpriteKind.Player)
```

### Step 2

This is the second step
    
```blocks
let mySprite = sprites.create(img`.`, SpriteKind.Player)
controller.moveSprite(mySprite)
```

### Step 3

Congratulations, you did it!
    
```blocks
let myEnemy: Sprite = null;
let mySprite = sprites.create(img`.`, SpriteKind.Player)
controller.moveSprite(myEnemy)
```

```template
scene.setBackgroundColor(9)
let mySprite = sprites.create(img`
    . . . . . . . . . . . . . . . . 
    . . . . . . . . . . . . . . . . 
    . . . . . . . . . b 5 5 b . . . 
    . . . . . . b b b b b b . . . . 
    . . . . . b b 5 5 5 5 5 b . . . 
    . b b b b b 5 5 5 5 5 5 5 b . . 
    . b d 5 b 5 5 5 5 5 5 5 5 b . . 
    . . b 5 5 b 5 d 1 f 5 d 4 f . . 
    . . b d 5 5 b 1 f f 5 4 4 c . . 
    b b d b 5 5 5 d f b 4 4 4 4 b . 
    b d d c d 5 5 b 5 4 4 4 4 4 4 b 
    c d d d c c b 5 5 5 5 5 5 5 b . 
    c b d d d d d 5 5 5 5 5 5 5 b . 
    . c d d d d d d 5 5 5 5 5 d b . 
    . . c b d d d d d 5 5 5 b b . . 
    . . . c c c c c c c c b b . . . 
    `, SpriteKind.Player)
controller.moveSprite(mySprite)
```

shakao avatar Jan 28 '22 17:01 shakao

Thanks! I really appreciate the help. It kind of works using the tutorial tool (For some reason, some of the blocks that were already present will sometimes be highlighted as well as the newly added ones), but it still seems a bit wonky when editing directly from the JavaScript tab in MakeCode Arcade. I'm still getting the "Unknown command" error. Maybe it only works with the Beta version? Anyway, I'm quite happy with the functionality of the "highlights" command, it gets the job done in a consistent way. I think I'll stick to that for now.

Yngel72 avatar Jan 31 '22 07:01 Yngel72