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

#1 2009-07-25 18:16:47

Coolsey
Scratcher
Registered: 2009-06-06
Posts: 20

the <if> script

how do you work the if script? i put it(if score=cpu's score say i win!) but when it was more the the cpu's score nothing happend.















I DON'T GET THE <if> SCRIPT! IT MAKES 0 SENSE!



<say[ die (if) script.]for(2)secs>  big_smile

Offline

 

#2 2009-07-25 18:18:46

Coolsey
Scratcher
Registered: 2009-06-06
Posts: 20

Re: the <if> script

<when[IF script  ]clicked>

<broadcast[ dead if script


<when I receive[ dead if script

<point towards( if script

<forever>
<move( 2 )steps>
<end>

<wait until><touching[ if script

<switch to costume[ punching if script

Last edited by Coolsey (2009-07-25 18:31:57)

Offline

 

#3 2009-07-25 18:19:45

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: the <if> script

Lol, the if statement is the  most basic and essential statements in all of programing

Anyways, what you are looking for is this

<if> <( <{ score }> <=>  <{  cpu score}> )>
<say[ you win  ]
<end>


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#4 2009-07-25 20:04:02

Coolsey
Scratcher
Registered: 2009-06-06
Posts: 20

Re: the <if> script

who are you and second the if script is broken so your wroung.

Offline

 

#5 2009-07-25 20:06:58

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: the <if> script

Code:

[when flag clicked]
[forever]
[][if <(your score) = (CPU's score)>]
[][][say (You win!)]
[][end of if]
[end of forever]

That should work.

Offline

 

#6 2009-07-26 00:42:26

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: the <if> script

Coolsey wrote:

who are you and second the if script is broken so your wroung.

It isn't broken, if it doesn't work you've just made a mistake somewhere.

Try one of the scripts posted earlier, they both work.

Last edited by hmnwilson (2009-07-26 00:43:11)


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#7 2009-07-26 00:47:53

fireball123
Scratcher
Registered: 2008-05-08
Posts: 1000+

Re: the <if> script

do you have a forever?


I did it for the Lolz

Offline

 

#8 2009-07-26 04:56:27

filo5
Scratcher
Registered: 2008-01-08
Posts: 1000+

Re: the <if> script

Maybe instead of [blocks]<( <{ score }> <=> <{ cpu score }> )>[/blocks], you should use [blocks]<( <{ score }> <>> <{ cpu score }> )>[/blocks].


Converting my Scratch projects to Python!

Offline

 

Board footer