This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-02 13:40:39

RuslanRuss
New Scratcher
Registered: 2013-02-02
Posts: 1

Why is condition "if" doesn't work in my script?

Hello everybody,

I am working on my script and have two issues I'd like to get your help with:
1)

when gf clicked
set <[score]> to zero 
repeat until <[score]> =[7]
end
I run the script and the score exceeds 7, but nothing happens...

2)
There are 2 sprites: a cowboy and a whip
When spacebar is pushed, the whip is shown and the cowboy spins it. By my device, when the whip touches a horse, a command must be run. But it works only from a several tries.

I'd really appreciate it if you could check the script and help me out.
Here is the project:
http://scratch.mit.edu/projects/RuslanRuss/3077689

Offline

 

#2 2013-02-02 14:07:06

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Why is condition "if" doesn't work in my script?

Here's a fixed version of the project.

I'll explain what i changed.
(1) wasn't working because you had a forever block.
For (2), i added a script to check if the whip is touching the horse while spinning, and also activated the broadcast.

Offline

 

#3 2013-02-02 21:48:33

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Why is condition "if" doesn't work in my script?

RuslanRuss wrote:

when gf clicked
set (score) to [0] 
repeat until <(score) = [7]>
end
I run the script and the score exceeds 7, but nothing happens...

You should be checking whether the score is above 6 - the score may increase too quickly for your script to check.

<(score) > [6]>
You could also check whether it's more than or equal to 7; the "technically correct, though not natively supported in Scratch" way.

<<(score) = [7]> or <(score) > [7]>>


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

Board footer