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

#1 2008-12-19 11:49:23

blahdeblah
Scratcher
Registered: 2008-02-19
Posts: 45

There's just something wrong here...

I was do something that involved dividing a variable by a number, but the end result would always turn out to be 0.
I did something like: set x to (variable/2), with the variable set to 100
but the sprite's x position would always return to 0, which is wrong...
ok, so i closed it, and reopened scratch, and everything works fine
I think the problem occurred when I was exporting a sprite.  The scripts are fine, but when I exported it and ran the exported sprite, the scripts were red, even though they worked with the original copy!

Offline

 

#2 2008-12-19 12:26:13

Dan01
Scratcher
Registered: 2008-06-11
Posts: 100+

Re: There's just something wrong here...

blahdeblah wrote:

I was do something that involved dividing a variable by a number, but the end result would always turn out to be 0.
I did something like: set x to (variable/2), with the variable set to 100
but the sprite's x position would always return to 0, which is wrong...
ok, so i closed it, and reopened scratch, and everything works fine
I think the problem occurred when I was exporting a sprite.  The scripts are fine, but when I exported it and ran the exported sprite, the scripts were red, even though they worked with the original copy!

If you mean that you imported a sprite, that already had the variable and script, then you are right. Sometimes the variable won't work if you didn't actually make the variable on that file -  which I have found many times.


http://img3.imageshack.us/img3/4743/ubd6522wp8.png
http://img3.imageshack.us/img3/4667/ubd3758ox2.png

Offline

 

#3 2008-12-19 13:11:51

blahdeblah
Scratcher
Registered: 2008-02-19
Posts: 45

Re: There's just something wrong here...

Dan01 wrote:

blahdeblah wrote:

I was do something that involved dividing a variable by a number, but the end result would always turn out to be 0.
I did something like: set x to (variable/2), with the variable set to 100
but the sprite's x position would always return to 0, which is wrong...
ok, so i closed it, and reopened scratch, and everything works fine
I think the problem occurred when I was exporting a sprite.  The scripts are fine, but when I exported it and ran the exported sprite, the scripts were red, even though they worked with the original copy!

If you mean that you imported a sprite, that already had the variable and script, then you are right. Sometimes the variable won't work if you didn't actually make the variable on that file -  which I have found many times.

thanks for the information  smile
I didn't know that

Offline

 

#4 2008-12-21 17:38:54

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

Re: There's just something wrong here...

blahdeblah wrote:

I was do something that involved dividing a variable by a number, but the end result would always turn out to be 0.
I did something like...

This is probably that scratch interpreted the value of the variable as a string. Whenever you try to apply any numerical operator to a string, scratch treats it as having a value of 0. So, 0/2=0! This could be because of a space after or before the zero, or some other string character.


"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

 

Board footer