Microsoft MakeCode

Any quicker way I can do this?

So I’m trying to put a shelf on every marked tile I described. Heres the code (get ready its a lot):

let redShelf = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf1 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf1 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf1 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf1 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf2 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf2 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf2 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf2 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf3 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf3 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf3 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf3 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf4 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf4 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf4 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf4 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf5 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf5 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf5 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf5 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf6 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf6 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf6 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf6 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf7 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf7 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf7 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf7 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf8 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf8 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf8 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf8 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf9 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf9 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf9 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf9 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

let redShelf0 = sprites.create(assets.imageredShelf0, SpriteKind.Shelf)

let yellowShelf0 = sprites.create(assets.imageyellowShelf, SpriteKind.Shelf)

let greenShelf0 = sprites.create(assets.imagegreenShelf, SpriteKind.Shelf)

let blueShelf0 = sprites.create(assets.imageblueShelf, SpriteKind.Shelf)

tiles.placeOnRandomTile(sprite, sprites.dungeon.floorDarkDiamond)

tiles.placeOnRandomTile(redShelf,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf2,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf3,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf2,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf3,assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf,assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf2, assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf3,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf2,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf3,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf4,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf5,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf6,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf4,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf5,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf6,assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf4,assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf5, assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf6,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf4,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf5,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf6,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf7,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf8,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf9,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf7,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf8,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf9,assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf7,assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf8, assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf9,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf7,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf8,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf9,assets.tilemyTile3)

tiles.placeOnRandomTile(redShelf0,assets.tilemyTile3)

tiles.placeOnRandomTile(yellowShelf0,assets.tilemyTile3)

tiles.placeOnRandomTile(greenShelf0,assets.tilemyTile3)

tiles.placeOnRandomTile(blueShelf0,assets.tilemyTile3)

Search up arrays!

Also you should put code between backticks so you don’t end up having a wall of text:
So this:
```typescript
// Code here
```
Becomes this:

// Code here

Much more readable and will have scrollbars when it gets very big - but you can’t edit posts anymore so one of the mods have to do it.

Arrays will change everything. But if you want to be simple, you can use the “For Value” in the Loop section :grinning: