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

#1 2012-01-24 16:40:59

fortmcas
Scratcher
Registered: 2009-07-26
Posts: 48

Tallying

I made a list on my new project triggered by touching selected platforms to get points.  How do i get it to total my list (points)

Fortmcas

Offline

 

#2 2012-01-24 17:03:04

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Tallying

If you want to find the sum of a list, just do this:

set [sum] to (0)
set [i] to (0)
repeat (length of [list]) times
{
     change [i] by (1)
     change [sum] by (item (i) of [list])
}


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#3 2012-01-24 17:11:15

fortmcas
Scratcher
Registered: 2009-07-26
Posts: 48

Re: Tallying

Can u do that in scratch blocks at the bottom of the page like this one:<play sound[  ]and waits>

Offline

 

#4 2012-01-24 17:25:01

fortmcas
Scratcher
Registered: 2009-07-26
Posts: 48

Re: Tallying

I just tried it, and I it is just bouncing around; one second is 2000, the next it is 10000

Fortmcas

Offline

 

#5 2012-01-24 18:01:29

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Tallying

Perhaps I misunderstood what you wanted.  Do you want script that adds up all the items in a list?  That is stored in "sum" after this script runs.

<set{ i }to( 0 )>
<set{ sum }to( 0 )>
<repeat( length of [list] )>
     <change{ i }by( 5 )>
     <change{ sum }by( item (i) of [list] )>
<end>


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#6 2012-01-24 18:17:54

fortmcas
Scratcher
Registered: 2009-07-26
Posts: 48

Re: Tallying

Yeah thats what I want, thanks!!!! is this the script for it?

Offline

 

#7 2012-01-24 18:21:29

fortmcas
Scratcher
Registered: 2009-07-26
Posts: 48

Re: Tallying

I cant do the last thing on your blocks, though.

Offline

 

#8 2012-01-24 18:48:23

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Tallying

There is an "item (1) of [list]" block under variables.  I'm changing the variable "sum" by "item (i) of [list]".  Just drag the "item (1) of [list]" into the oval part of "change [sum]  by()", and drag (i) into the oval part of item (1) of [list]


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#9 2012-01-24 18:56:30

fortmcas
Scratcher
Registered: 2009-07-26
Posts: 48

Re: Tallying

Thanks for helping me!!!!! I have a new game out called Winnie the Pooh, The Videogame.  It is for school. 

Fortmcas

Offline

 

Board footer