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

#1 2009-10-10 21:14:19

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

sqrt is not valid for x > 0

Code:

Float(Object)>>error: 
Float>>sqrt
Point>>r 
Point>>rotateBy:about: 
[] in WarpBit class>>rotate:degress:center:scaleBy:smoothing:  
Array(SequenceableCollection)>>collect:
WarpBit class>>rotate:degress:center:scaleBy:smoothing: 
ScratchSpriteMorph>>generateRotatedForm
ScratchSpriteMorph>>layoutChanged 
ScratchSpriteMorph(ScriptableScratchMorph)>>costumeChanged

Can someone tell me what that means?
It's annoing
I ment 'x < 0' not 'x > 0'

Last edited by ThePCKid (2009-10-11 13:28:12)

Offline

 

#2 2009-10-11 01:57:46

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: sqrt is not valid for x > 0

I take it this happened when you tried to 'turn (sqrt (###) ) degrees', of something along those lines. Also, are you sure you didn't make a typo? It is true that you cannot take the square root of a negative number (x < 0), but what you said, x > 0, should work. To avoid this problem, extending it to (abs(sqrt(x) ) ) will do the trick. A slightly more thorough, although sometimes mathematically incorrect way would be
<if><(<{ x }><<>0)>
<set{ y }to(( 0 <-> <abs( sqrt(x) )) )) ))
<else>
<set{ y }to <abs( sqrt(x)) ))
<end>
[/blocks]
If you provided more information, I could help you further.

Last edited by billyedward (2009-10-11 02:00:23)


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#3 2009-10-11 02:02:06

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: sqrt is not valid for x > 0

Another thing:
You are using scratch 1.0 with error catching turned off, right?
If you use a more up-to-date version, then the script will simply turn red, no bothersome walkback error.


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#4 2009-10-11 13:30:35

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: sqrt is not valid for x > 0

billyedward wrote:

Another thing:
You are using scratch 1.0 with error catching turned off, right?
If you use a more up-to-date version, then the script will simply turn red, no bothersome walkback error.

I have Scratch 1.4. There is no error catching

Offline

 

#5 2009-10-12 19:55:05

scratch_yoshi
Scratcher
Registered: 2009-06-12
Posts: 1000+

Re: sqrt is not valid for x > 0

ThePCKid wrote:

billyedward wrote:

Another thing:
You are using scratch 1.0 with error catching turned off, right?
If you use a more up-to-date version, then the script will simply turn red, no bothersome walkback error.

I have Scratch 1.4. There is no error catching

Wierd... If you open up the Jetpack_Girl sprite's scripts, where it says [blocks]<abs( [/blocks], it will be red instead of green. So you should re-download Scratch 1.4 and see if that helps!


Retired from Scratch, but just the language itself. Not the forums.

Offline

 

#6 2009-10-12 20:07:42

scratch_yoshi
Scratcher
Registered: 2009-06-12
Posts: 1000+

Re: sqrt is not valid for x > 0

I don't know what this means:

Code:

Float(Object)>>error: 
Float>>sqrt
Point>>r 
Point>>rotateBy:about: 
[] in WarpBit class>>rotate:degress:center:scaleBy:smoothing:  
Array(SequenceableCollection)>>collect:
WarpBit class>>rotate:degress:center:scaleBy:smoothing: 
ScratchSpriteMorph>>generateRotatedForm
ScratchSpriteMorph>>layoutChanged 
ScratchSpriteMorph(ScriptableScratchMorph)>>costumeChanged

But you might be using the sqrt block wrong. Also, look at this line:

Code:

ScratchSpriteMorph>>generateRotadedForm

That might have something to do with
[blocks]<turn cw(  )degrees>[/blocks]and[blocks]<turn cw(  )degrees>[/blocks]but I could be wrong.
Also, the line

Code:

ScratchSpriteMorph(ScriptableScratchMorph)>>costumeChanged

might have something to do with
[blocks]<switch to costume[ [/blocks]or[blocks]<next costume>[/blocks]


Retired from Scratch, but just the language itself. Not the forums.

Offline

 

Board footer