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

#1 2011-06-18 19:03:27

Elitecough
New Scratcher
Registered: 2011-06-17
Posts: 3

red line around script...What does it mean???

I've made a rather basic game, which works fine except for one thing, the accuracy variable. It stays on 0 no matter what. I've got it set to:

When flag clicked
forever"
set (accuracy) to (shots hit)/(shots)
"



[blocks]http://scratch.mit.edu/forums/viewtopic.php?id=66160#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?id=66160#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?id=66160#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?id=66160#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?id=66160#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?id=66160#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?id=66160#req_message[/blocks]

What am I doing wrong?

Offline

 

#2 2011-06-18 19:48:14

Elitecough
New Scratcher
Registered: 2011-06-17
Posts: 3

Re: red line around script...What does it mean???

Hmmn....BBCode didn't seem to work.

http://i55.tinypic.com/1182ioh.gif

^^^

Offline

 

#3 2011-06-18 20:02:54

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: red line around script...What does it mean???

A script turns red when you make it divide by 0  tongue  I think that's what you're doing...


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#4 2011-06-18 20:10:13

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

Re: red line around script...What does it mean???

The red line means there's an impossible calculation in your script, such as trying to divide something by 0. If "shots" is set to 0, the script can't proceed because it can't divide by 0.

So, the solution would be to not perform that calculation while shots = 0. One way we could do that is by using this script:
http://www.freeimagehosting.net/uploads/3a2b505f6c.gif
That should fix the problem.

Does that help?

Last edited by hmnwilson (2011-06-18 20:11:22)


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

 

#5 2011-06-18 21:18:47

Elitecough
New Scratcher
Registered: 2011-06-17
Posts: 3

Re: red line around script...What does it mean???

Yup! Thanks!

Offline

 

#6 2011-06-18 23:42:49

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

Re: red line around script...What does it mean???

A script gets a red outline when any error of that kind happens methinks.


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

Offline

 

Board footer