This is made for a specific Scratch user to fix one of their projects.
You need to use an "and" block...lets look at your code
[blocks]
<if> <<( <{ red health }> <<> 70 )>
<switch to costume[ red 75 health
<end>
<if> <<( <{ red health }> <<> 51 )>
<switch to costume[ red 50 health
<end>
<if> <<( <{ red health }> <<> 30 )>
<switch to costume[ red 25 health
<end>
[/blocks]
The problem is that when the red health = 20, all three of the above if statements are true, and the stick figure goes through all of the costumes. To fix it, say
[blocks]
<if> << <( 51 <<> <{ red health }> )> <and> <<( <{ red health }> <<> 70 )> >>
<switch to costume[ red 75 health
<end>
<if> << <( 30 <<> <{ red health }> )> <and> <<( <{ red health }> <<> 51 )> >>
<switch to costume[ red 50 health
<end>
<if> <<( <{ red health }> <<> 30 )>
<switch to costume[ red 25 health
<end>
[/blocks]
Using the "and" block, you can create a range that you want to test. Hope this helps.
Paulmedwal
Last edited by paulmedwal (2007-08-17 12:01:14)
Offline
Alternatively, if this is not part of a continuos loop, you could simply put them in ascending order (check <30, check <50, check <60) then put a stop command after the first and second costume change.
Offline
[block]
<if> <( red health <<> 30 )>
<switch to costume[ red 25 health
<else>
<if> <( red health <<> 51 )>
<switch to costume[ red 50 health
<else>
<if> <( red health <<> 70 )>
<switch to costume[ red 75 health
<end>
<end>
<end>
[/block]
would do only as many tests as needed, and avoids the awkward ands.
Last edited by kevin_karplus (2007-08-17 17:17:00)
Offline
For the red guy's script...you just need to make the health for both the blue and red guy set to 100.
[blocks]
<when green flag clicked>
<set{ Blue Health }to( 100
<set{ red Health }to( 100
<reset timer>
...
[/blocks]
Do the same for the blue guy.
Paulmedwal
Offline
If "red health" and "blue health" are both global variables, then each one only needs to be initialized in one <when greenflag clicked> script.
Offline