Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Counter Bug
- DashDav
-
Scratcher
14 posts
Counter Bug
INTRODUCTION
So I’m making a game called Pizza Clicker, which used to run normally, but recently I’ve realized it’s been quite janky. The counter will not process the number ‘0’, even though I haven’t tweaked any code or costumes, and it was just fine.
HISTORY
I first figured this out today when I booted up Pizza Clicker and the counter didn’t show anything (which, is obvious from the above; the game starts you off with 0 pizzas, and the counter couldn’t process 0s, so it didn’t show). I found this peculiar because I didn’t remember touching it the past few days. So I looked into the code to show the sprite, and it was. Now, the thing is, the counter—like pretty much any other—relies heavily on costumes and operations (however that was predominantly, if not entirely, for the purpose of motion and alignment, NOT processing). So I checked, and it just so happened to be in place, with perfect maintenance. I clicked on the ‘Switch Costume To <0>’ block in an attempt to manually get it up, which did not work, even when putting the block after the block that processed it. And then I started panicking; and so I came to the forums, and that’s pretty much the entire story. The code (, which is a modified version of a tutorial from Jackson Academy ) is below.
CODE
So I’m making a game called Pizza Clicker, which used to run normally, but recently I’ve realized it’s been quite janky. The counter will not process the number ‘0’, even though I haven’t tweaked any code or costumes, and it was just fine.
HISTORY
I first figured this out today when I booted up Pizza Clicker and the counter didn’t show anything (which, is obvious from the above; the game starts you off with 0 pizzas, and the counter couldn’t process 0s, so it didn’t show). I found this peculiar because I didn’t remember touching it the past few days. So I looked into the code to show the sprite, and it was. Now, the thing is, the counter—like pretty much any other—relies heavily on costumes and operations (however that was predominantly, if not entirely, for the purpose of motion and alignment, NOT processing). So I checked, and it just so happened to be in place, with perfect maintenance. I clicked on the ‘Switch Costume To <0>’ block in an attempt to manually get it up, which did not work, even when putting the block after the block that processed it. And then I started panicking; and so I came to the forums, and that’s pretty much the entire story. The code (, which is a modified version of a tutorial from Jackson Academy ) is below.
CODE
when green flag clicked
show
counter clones
define counter clones
set [clone] to [1]
go to x: (180) y: (0)
repeat (10)
create clone of [myself]
change [clone] by (1)
change x by (25)
end
when I start as a clone
forever
if <not <(costume name) = (letter (clone) of (pizza))>> then
switch costume to (letter (clone) of (pizza))
end
go to x: ((((clone) - (0.5)) - ((length of (pizza)) / (2))) * (25)) y: (160)
end
- Ranger_07
-
Scratcher
100+ posts
Counter Bug
So I checked your project and it seemed to work fine? Did you fix it?
Otherwise you could try renaming each of the costume to “#1”, “#2”, “#3” and so on, then swap the switch costume to block with this:
Otherwise you could try renaming each of the costume to “#1”, “#2”, “#3” and so on, then swap the switch costume to block with this:
switch costume to (join [#] (letter (clone) of (pizza)))
- Discussion Forums
- » Help with Scripts
-
» Counter Bug

