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
Hmmn....BBCode didn't seem to work.
http://i55.tinypic.com/1182ioh.gif
^^^
Offline
A script turns red when you make it divide by 0
I think that's what you're doing...
Offline
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:
That should fix the problem.
Does that help?
Last edited by hmnwilson (2011-06-18 20:11:22)
Offline
Yup! Thanks!
Offline
A script gets a red outline when any error of that kind happens methinks.
Offline