I was making a factorial script, like this:
when gf clicked ask [something] and wait set [input v] to (answer) set [data v] to (answer) repeat until << (data) = [0] > or < (data) < [1] >> set [data v] to ((data)*((data)-(1))) change [data v] by [-1]And that's my script. Input and another variable, Output, were showing. Data was not. I tried to look at Data and it make my computer crash.
Last edited by Firedrake969 (2012-07-13 17:47:56)
Offline
Did you set a effect or something like that to data?
Offline
like turn [] degrees, change x by [], change size by [], set [ v] effect to [], etc.
Offline
No... I had no movement blocks. That one script was my only script.
Offline
Hm...
Were you running it when the crash happened...
Offline
Sometimes computers crash for other reasons so we can't even be sure it was caused by Scratch.
But I think that maybe the "data" variable was set to an incredibly large number and showing it used up all of Scratch's memory.
Offline
No. I set the input as five. 5*4*3*2*1 is only 144. Anyways, it once was at infinity when it was variable*variable.
Offline
Wes64 wrote:
Sometimes computers crash for other reasons so we can't even be sure it was caused by Scratch.
But I think that maybe the "data" variable was set to an incredibly large number and showing it used up all of Scratch's memory.
Um...
WAIT...
I recreated this script, and a colored wheel replaced the mouse pointer...
That means it's thinking, and not responding...
Offline
Firedrake969 wrote:
No. I set the input as five. 5*4*3*2*1 is only 144. Anyways, it once was at infinity when it was variable*variable.
That isn't how your script works.
Data input is 5
5*4 = 20
Data is set to 20 and changed by -1.
19*18 = 342
Data is set to 342 and changed by -1.
342*341 = 116622
Data is set to 116622 and changed by -1.
116622*116621 = a lot
And the number keeps getting bigger and bigger, which drained your memory.
Last edited by Wes64 (2012-07-13 18:14:38)
Offline
Wes64 wrote:
Firedrake969 wrote:
No. I set the input as five. 5*4*3*2*1 is only 144. Anyways, it once was at infinity when it was variable*variable.
That isn't how your script works.
Data input is 5
5*4 = 20
Data is set to 20 and changed by -1.
19*18 = 342
Data is set to 342 and changed by -1.
342*341 = 116622
Data is set to 116622 and changed by -1.
116622*116621 = a lot
And the number keeps getting bigger and bigger, which drained your memory.
Until it reaches infinity, of course...
Offline
GreenCloud wrote:
Wes64 wrote:
Firedrake969 wrote:
No. I set the input as five. 5*4*3*2*1 is only 144. Anyways, it once was at infinity when it was variable*variable.
That isn't how your script works.
Data input is 5
5*4 = 20
Data is set to 20 and changed by -1.
19*18 = 342
Data is set to 342 and changed by -1.
342*341 = 116622
Data is set to 116622 and changed by -1.
116622*116621 = a lot
And the number keeps getting bigger and bigger, which drained your memory.Until it reaches infinity, of course...
And then makes scratch close: http://wiki.scratch.mit.edu/wiki/Making_Scratch_Close
Anyway, factorials are more suited for bignums, like this.
PS. 5*4*3*2*1 is 120, not 144.
Offline
Molybdenum wrote:
GreenCloud wrote:
Wes64 wrote:
That isn't how your script works.
Data input is 5
5*4 = 20
Data is set to 20 and changed by -1.
19*18 = 342
Data is set to 342 and changed by -1.
342*341 = 116622
Data is set to 116622 and changed by -1.
116622*116621 = a lot
And the number keeps getting bigger and bigger, which drained your memory.Until it reaches infinity, of course...
And then makes scratch close: http://wiki.scratch.mit.edu/wiki/Making_Scratch_Close
Anyway, factorials are more suited for bignums, like this.
PS. 5*4*3*2*1 is 120, not 144.
Oops. My mistake. Anyways, my computer HAS gone to infinity before.
Offline
3sal2 wrote:
Script bug. Move to Help With Scripts.
Yeah, its a BUG. This is a forum for BUGS and glitches. Trust me, its in the right place.
Offline
Firedrake969 wrote:
Ok. Anyways, what happened?
The malfunctioning script caused scratch to force-quit.
Scratch Wiki wrote:
This script will fill Squeak's memory, and will force it to close. Squeak automatically crashes when a variable reaches a very high amount as it doesn't have the memory to maintain it. Since Scratch runs within the Squeak environment, Scratch closes when the Squeak environment closes. If a high RAM has been allotted to Scratch, it may just say "Infinity", and not close.
Offline
Wes64 wrote:
Firedrake969 wrote:
Ok. Anyways, what happened?
The malfunctioning script caused scratch to force-quit.
Scratch Wiki wrote:
This script will fill Squeak's memory, and will force it to close. Squeak automatically crashes when a variable reaches a very high amount as it doesn't have the memory to maintain it. Since Scratch runs within the Squeak environment, Scratch closes when the Squeak environment closes. If a high RAM has been allotted to Scratch, it may just say "Infinity", and not close.
I wrote that part about the "Infinity". Anyways, it normally goes to infinity...
Offline
Maybe something else -- some other program -- was using a lot of memory so squeak had less to work with.
Offline
Oh well, just dont ramp a variable up to infinity in the future and you should be fine.
Offline
I'll try again and see if it crashes.
Edit: It did, but i was running 3 tabs in chrome and a tab in IE.
Last edited by Firedrake969 (2012-07-14 19:42:55)
Offline
Wes64 wrote:
3sal2 wrote:
Script bug. Move to Help With Scripts.
Yeah, its a BUG. This is a forum for BUGS and glitches. Trust me, its in the right place.
No it isn't (It's about a scripting problem).
Offline
The correct script is:
when gf clicked set [n! v] to [1] ask [Number?] and wait set (n) to (answer) if <(n) > [0]> set [m v] to [1] repeat ((n) - (1)) change [m v] by (1) set [n! v] to ((n!) * (m)) end else if <(n) < [0]> set [m v] to [-1] repeat (([abs v] of (n)) - (1)) change [m v] by (-1) set [n! v] to ((n!) * (m)) end end end say (join [The answer is ] (n!)) for ((length of (join [The answer is ] (n!)))/ (10)) secsYou just built your script wrong.
Last edited by 3sal2 (2012-07-16 15:25:06)
Offline