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

#1 2012-12-23 05:01:49

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

"(distance to (mouse x))"

Doing the script:

(distance to (mouse x))
always gives the result "10000" regardless of how far it is away. Tested on Scratch 1.4 with OS X Lion. The bug also occurs with other reporters such as "costume #" and "loudness", all with the result "10000".


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#2 2012-12-23 09:22:29

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: "(distance to (mouse x))"

This is because mouse x is a number not a co-ordinate. Therefore it assumes the co-ordinate is x: every possible number at the same time, y: every possible number at the same time. It then gets confused and sets itself to the highest it can go.

Offline

 

#3 2012-12-23 10:56:47

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: "(distance to (mouse x))"

the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:

( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y))))

Offline

 

#4 2012-12-23 11:25:14

mmww
Scratcher
Registered: 2010-01-14
Posts: 500+

Re: "(distance to (mouse x))"

LS97 wrote:

the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:

(distance to( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y)))))

Fixed.... I think


http://i.imgur.com/AWFFO.pnghttp://www.weebly.com/uploads/1/0/1/4/10146167/4363061_orig.png Save the cheese!
I am http://blocks.scratchr.org/API.php?action=onlineStatus&user=mmww

Offline

 

#5 2012-12-23 12:20:36

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: "(distance to (mouse x))"

mmww wrote:

LS97 wrote:

the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:

(distance to( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y)))))

Fixed.... I think

no. it was right the first time. that IS the distance formula already, what you wrote is the distance formula of a distance formula


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#6 2012-12-27 08:30:11

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: "(distance to (mouse x))"

The reporter shouldn't even fit in in the first place.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#7 2012-12-27 11:48:32

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: "(distance to (mouse x))"

LS97 wrote:

the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:

( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y))))

That's the distance from the mouse to the centre. Do ((mouse x) - (x position)) and ((mouse y) - (y position)) instead.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#8 2012-12-27 20:54:45

scratchisthebest
Scratcher
Registered: 2009-02-08
Posts: 500+

Re: "(distance to (mouse x))"

jontmy00 wrote:

The reporter shouldn't even fit in in the first place.


bye 1.4, we all loved you. but we all outgrew the site. 2.0 is a welcome change.
http://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.png

Offline

 

#9 2012-12-28 09:37:56

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: "(distance to (mouse x))"

jontmy00 wrote:

The reporter shouldn't even fit in in the first place.

Bingo.

LS's script is the mathematical equation of figuring out a distance, so yeah, use that.

This would figure out the distance in total, but if you only want the X distance, use

((mouse x) - (x position))
Put an ABS on that if you want the absolute distance, regardless of direction.  smile

Offline

 

#10 2012-12-29 01:58:25

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: "(distance to (mouse x))"

Okay, topic not so resolved. I want the ST's confirmation because it still fits in in 2.0 but reports "0", which is different from 1.4.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#11 2012-12-30 21:36:07

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: "(distance to (mouse x))"

Bump.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#12 2012-12-30 21:41:38

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: "(distance to (mouse x))"

jontmy00 wrote:

Okay, topic not so resolved. I want the ST's confirmation because it still fits in in 2.0 but reports "0", which is different from 1.4.

In reality, there is no answer to the function you gave as it'd be like saying

(distance to (9000))
The only reason (I think) it returns 0 or 10000 is because there is some sort of coding that makes that the default value; after all, if it returned null or an error, it could screw up some projects


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#13 2012-12-30 21:59:48

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: "(distance to (mouse x))"

SJRCS_011 wrote:

jontmy00 wrote:

Okay, topic not so resolved. I want the ST's confirmation because it still fits in in 2.0 but reports "0", which is different from 1.4.

In reality, there is no answer to the function you gave as it'd be like saying

(distance to (9000))

I know that.  tongue

SJRCS_011 wrote:

The only reason (I think) it returns 0 or 10000 is because there is some sort of coding that makes that the default value; after all, if it returned null or an error, it could screw up some projects

But it is different between the 2 versions, so why?


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#14 2012-12-30 22:06:47

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: "(distance to (mouse x))"

Flash isn't Squeak.  Their null returns different values.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#15 2012-12-30 22:12:15

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: "(distance to (mouse x))"

Firedrake969 wrote:

Flash isn't Squeak.  Their null returns different values.

Let me make a test project before this gets closed...


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#16 2012-12-30 22:25:08

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: "(distance to (mouse x))"

Here is the test project.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

Board footer