Discuss Scratch
- dracae
-
1000+ posts
Beginner with many questions.
Well, you could have a variable “Amount Of Windows Fixed”
Whenever the game starts, set it to 0.
Then, every time a window is fixed, the variable would be increased by 1.
Hope I helped!
Whenever the game starts, set it to 0.
Then, every time a window is fixed, the variable would be increased by 1.
Hope I helped!

- drmcw
-
1000+ posts
Beginner with many questions.
After some time off to work on other things, I'm looking for a little more help. I have a question regarding clones:
I'm trying to find a way to detect that all my windows are “fixed”. This will then end the game, but I can change that to end a level in the future. I have made clone windows in my game. Each window is a clone and randomly chooses a costume at the start of the game showing either fixed or two different broken costumes. The main character, Ralph, fixes windows by changing broken ones (costume 2 or 3) to fixed windows (costume 1). I'm not sure if my script for detecting all windows are fixed (costume 1) is faulty or if because the windows are clones, Scratch doesn't keep track of each clones costume. Do clones register as individual sprites to the point where Scatch would know which costume each clone is currently on or does it just track the original sprite?
If Scratch does not know the costume of each clone, is there a different way to end the game/complete the level upon the fixing of each window?
http://scratch.mit.edu/projects/10352728
Clones are very useful but annoying at times, obviously scratch does know what costume each one has but won't allow you access to that information. You'll probably find that you can get the clone's costume if you use the costume # monitor within a when I start as a clone stack but using it anywhere else will just return the sprite's costume. To get around this, as dracae says, you'll have to duplicate the information using variables. In this case probably just have a “broken window” or “fixed window” variable and decrement or increment as windows are fixed. Then just check for 0 or however many windows there are to know when the level is complete.
Last edited by drmcw (June 13, 2013 04:36:38)
- ErnieParke
-
1000+ posts
Beginner with many questions.
Well, it looks like dracae just did what I was about to do, and so I'd recommend looking at his post above. ;)No, Scratch cannot simply access each clones costumes ( After some time off to work on other things, I'm looking for a little more help. I have a question regarding clones:nor variables), which I heard has been an issue with various Scratchers in their programs. Although you can't access the costumes directly, you can still access them with a bit of code. It's late where I am, though I'll come back by tomorrow morning. ;)
I'm trying to find a way to detect that all my windows are “fixed”. This will then end the game, but I can change that to end a level in the future. I have made clone windows in my game. Each window is a clone and randomly chooses a costume at the start of the game showing either fixed or two different broken costumes. The main character, Ralph, fixes windows by changing broken ones (costume 2 or 3) to fixed windows (costume 1). I'm not sure if my script for detecting all windows are fixed (costume 1) is faulty or if because the windows are clones, Scratch doesn't keep track of each clones costume. Do clones register as individual sprites to the point where Scatch would know which costume each clone is currently on or does it just track the original sprite?
If Scratch does not know the costume of each clone, is there a different way to end the game/complete the level upon the fixing of each window?
http://scratch.mit.edu/projects/10352728
With regards,
ErnieParke
P.S. I hadn't gotten a chance to say this yet, but hello mgrobbel and welcome to Scratch! I hope that you have a wonderful time here!
With regards,
ErnieParke
- mwiedmann
-
100+ posts
Beginner with many questions.
Whenever Freddy fixes a window, have him “broadcast window_count and wait”. Each window will respond to this broadcast, so using dracae's global variable idea, increment the variable only if the window is still broken. Freddy can then check if BrokenWindows=0 then next level.
- turkey3
-
1000+ posts
Beginner with many questions.
The way to detect clones' costumes is using a local variable for each clone representing its costume# and another variable representing its clone number, and that clone has to insert the costume number in item clone# of a list of clones' costumes. I know that sounds confusing

- mgrobbel
-
9 posts
Beginner with many questions.
When I get a chance, I'll try and figure out what you've all said and implement it. This is the best part of Scratch in my opinion-trying to figure out solutions to problems. I'm sure I'll be back to ask questions if I can't get it to work. Thank you for giving me a starting point. Global variable and check that variable upon window fix. Got it.
- mgrobbel
-
9 posts
Beginner with many questions.
Quick question: What happens when I have made a broadcast message, but it doesn't show up from the pull down list on another sprite? This seems to happen to me occasionally?
- drmcw
-
1000+ posts
Beginner with many questions.
Never come across that. Either a bug or you haven't created the broadcast message as you expected. Quick question: What happens when I have made a broadcast message, but it doesn't show up from the pull down list on another sprite? This seems to happen to me occasionally?
- ErnieParke
-
1000+ posts
Beginner with many questions.
Well if that happens, then that means your already using the “hidden” broadcast message in that block, or at least that's what should be the case. By chance, is something else happening during these situations? Quick question: What happens when I have made a broadcast message, but it doesn't show up from the pull down list on another sprite? This seems to happen to me occasionally?
With regards,
ErnieParke
- turkey3
-
1000+ posts
Beginner with many questions.
The wiki has an article called Detecting Clones that might be helpful for you.
- eastons
-
25 posts
Beginner with many questions.
Here is a sample project to check status of clones to apply a win condition
http://scratch.mit.edu/projects/11112307/
What you can do is have a counter variable call it CountOfWindowClones.
On start give it a value of 1.
Now create a list called WindowState.
Now create a local variable for the window sprite called MyID
In Window Sprite::
When I start as clone {
Set MyID to CountofWindowClones
Change CountofWindowClones by +1
Add “MyRandomWindowState” to WindowState
}
When MyWindowState is Changed
replace item (MyID) of WindowState with “NewState”
Now in you main loop
Wait until <not <WindowState Contains “BROKEN” >>
YOU WIN!
PLEASE! Someone show me a better way
Eastons
http://scratch.mit.edu/projects/11112307/
What you can do is have a counter variable call it CountOfWindowClones.
On start give it a value of 1.
Now create a list called WindowState.
Now create a local variable for the window sprite called MyID
In Window Sprite::
When I start as clone {
Set MyID to CountofWindowClones
Change CountofWindowClones by +1
Add “MyRandomWindowState” to WindowState
}
When MyWindowState is Changed
replace item (MyID) of WindowState with “NewState”
Now in you main loop
Wait until <not <WindowState Contains “BROKEN” >>
YOU WIN!
PLEASE! Someone show me a better way

Eastons
Last edited by eastons (June 27, 2013 04:41:15)