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
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.
Offline
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
I didn't know that
Offline
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.
Offline