mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Add one to index if random costume is current costume
This commit is contained in:
parent
3f1c4aa2d8
commit
8e9f9e0a30
1 changed files with 3 additions and 5 deletions
|
@ -346,11 +346,9 @@ class Scratch3LooksBlocks {
|
|||
} else if (requestedCostume === 'random backdrop') {
|
||||
const numCostumes = target.getCostumes().length;
|
||||
if (numCostumes > 1) {
|
||||
let index;
|
||||
do {
|
||||
index = Math.floor(Math.random() * numCostumes);
|
||||
} while (index === target.currentCostume);
|
||||
target.setCostume(index);
|
||||
let selectedIndex = Math.floor(Math.random() * (numCostumes - 1));
|
||||
if (selectedIndex === target.currentCostume) selectedIndex += 1;
|
||||
target.setCostume(selectedIndex);
|
||||
}
|
||||
} else {
|
||||
const forcedNumber = Number(requestedCostume);
|
||||
|
|
Loading…
Reference in a new issue