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

#1 2012-02-23 19:02:03

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

How to make a list go back through itself!

I need help! I need to make a lIst go back through itself! How do I do it?


Get ready for domination of:  tongue

Offline

 

#2 2012-02-23 20:04:57

TheScript
New Scratcher
Registered: 2012-02-23
Posts: 6

Re: How to make a list go back through itself!

you can do:

<when I recieve [go through]>
add (Other Variable) to [list]

Offline

 

#3 2012-02-23 20:20:19

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

TheScript wrote:

you can do:

<when I recieve [go through]>
add (Other Variable) to [list]

I am just a little bit confused...


Get ready for domination of:  tongue

Offline

 

#4 2012-02-23 20:29:16

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: How to make a list go back through itself!

Go back through itself? What do you mean?


6418,

Offline

 

#5 2012-02-23 21:03:48

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

CheeseMunchy wrote:

Go back through itself? What do you mean?

I'm trying to make a game, and there's a list called colors and, i need it to go through itself again. I'll upload it.

Last edited by coolhogs (2012-02-23 21:06:21)


Get ready for domination of:  tongue

Offline

 

#6 2012-02-24 12:00:37

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: How to make a list go back through itself!

What do you mean? Make the order reverse?


Why

Offline

 

#7 2012-02-24 14:13:10

ProgramCAT
Scratcher
Registered: 2011-12-13
Posts: 500+

Re: How to make a list go back through itself!

Use:

when I receive [gothrough v]
set [i v] to [1]
repeat (length of [colors v])
do stuff
change [i v] by [1]
end

Or:

when I receive [gobackthrough v]
set [i v] to (length of [colors v])
repeat (i)
do stuff
change [i v] by [-1]
end
If you want to reverse the order of the items in a list, use this:
when I receive [reverse v]
set [i v] to (length of [colors v])
repeat (i)
add (item (i) of [colors v] ) to [templist v]
change [i v] by [-1]
end
set [i v] to [1]
repeat (length of [templist v])
replace item (i) of [colors v] with (item (i) of [templist v])
change [i v] by [1]
end
delete (all v) of [templist v]
It should work...

Last edited by ProgramCAT (2012-02-24 15:41:02)


Programming is an art...
Goodbye, Scratch. I am leaving because of the exams coming up at our school, though I'll check the forums once or twice a week.

Offline

 

#8 2012-02-24 15:25:17

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

Re: How to make a list go back through itself!

What do you mean by "go through itself"?


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

Offline

 

#9 2012-02-24 16:32:24

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: How to make a list go back through itself!

What exactly do you want the script to do?


http://trinary.tk/images/signature_.php

Offline

 

#10 2012-02-24 16:42:00

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

trinary wrote:

What exactly do you want the script to do?

I want the script to clone (more like stamping) the sprite and I want it to be a 1s1s project

Last edited by coolhogs (2012-02-24 16:46:43)


Get ready for domination of:  tongue

Offline

 

#11 2012-02-24 17:10:36

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

Re: How to make a list go back through itself!

Like this?

When I Receive [render]
set [i] to (1)
go to x:(180) y:(-240)
repeat(24)
repeat(18)
switch to costume (item (i) of [list])
stamp
change x by (20)
change [i] by (1)
end
set x to (-240)
change y by (-20)
end


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

Offline

 

#12 2012-02-24 17:15:31

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

MoreGamesNow wrote:

Like this?

When I Receive [render]
set [i] to (1)
go to x:(180) y:(-240)
repeat(24)
repeat(18)
switch to costume (item (i) of [list])
stamp
change x by (20)
change [i] by (1)
end
set x to (-240)
change y by (-20)
end

no, i'm trying to do it without stamping.


Get ready for domination of:  tongue

Offline

 

#13 2012-02-24 21:08:35

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

Re: How to make a list go back through itself!

Cloning is currently impossible in Scratch (at least, without "hacking").  I'm still not sure what "going through itself" means.


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

Offline

 

#14 2012-02-24 21:15:44

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

MoreGamesNow wrote:

Cloning is currently impossible in Scratch (at least, without "hacking").  I'm still not sure what "going through itself" means.

i mean like if you have a list and you want it to go through and pick out different colors and draw the results... like if you have green, and you want the sprite to draw the color.


Get ready for domination of:  tongue

Offline

 

#15 2012-02-24 21:27:16

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

Re: How to make a list go back through itself!

Like this?

When I Receive [draw]
set [i] to (0)
repeat(length of [list])
change [i] by (1)
if<(item (i) of [list]) = [red]>
set pen color to [red]
else
if<(item (i) of [list]) = [blue]>
set pen color to [blue]
else
if<(item (i) of [list]) = [green]>
set pen color to [green]
end
end
end
draw stuff
end
You can't select color based off of variables directly in Scratch (I believe you can in Panther though).  A more efficient approach than the if-else statements may be to use the block:

set pen color to (item (i) of [list])

Last edited by MoreGamesNow (2012-02-24 21:29:00)


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

Offline

 

#16 2012-02-24 21:32:17

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

MoreGamesNow wrote:

Like this?

When I Receive [draw]
set [i] to (0)
repeat(length of [list])
change [i] by (1)
if<(item (i) of [list]) = [red]>
set pen color to [red]
else
if<(item (i) of [list]) = [blue]>
set pen color to [blue]
else
if<(item (i) of [list]) = [green]>
set pen color to [green]
end
end
end
draw stuff
end
You can't select color based off of variables directly in Scratch (I believe you can in Panther though).  A more efficient approach than the if-else statements may be to use the block:

set pen color to (item (i) of [list])

Thanks I've tested it, and it worked great. But there's a problem. I was trying to upload it, but it went on forever. (I had to force quit it.) Could you possibly make it so that it doesn't have repeat blocks, if it's possible.

Last edited by coolhogs (2012-02-24 22:13:04)


Get ready for domination of:  tongue

Offline

 

#17 2012-02-24 22:34:08

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

MoreGamesNow wrote:

Like this?

When I Receive [draw]
set [i] to (0)
repeat(length of [list])
change [i] by (1)
if<(item (i) of [list]) = [red]>
set pen color to [red]
else
if<(item (i) of [list]) = [blue]>
set pen color to [blue]
else
if<(item (i) of [list]) = [green]>
set pen color to [green]
end
end
end
draw stuff
end
You can't select color based off of variables directly in Scratch (I believe you can in Panther though).  A more efficient approach than the if-else statements may be to use the block:

set pen color to (item (i) of [list])

For this one, you can't put a () block in a color.  smile


Get ready for domination of:  tongue

Offline

 

#18 2012-02-24 23:06:00

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

Re: How to make a list go back through itself!

coolhogs wrote:

For this one, you can't put a () block in a color.  smile

There are two "set pen color to" blocks.  One accepts "round" blocks and the other is the color square.  For the color square one (first one mentioned above), you need to use if-else statements and manually set the color.  For the second one, you can change the color by setting it to a variable's number.

Also, when I said "set color to [green]", that was using the color-square-block.  I don't know how to put in actual colors with the scratch blocks  smile


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

Offline

 

#19 2012-02-24 23:12:08

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

MoreGamesNow wrote:

coolhogs wrote:

For this one, you can't put a () block in a color.  smile

There are two "set pen color to" blocks.  One accepts "round" blocks and the other is the color square.  For the color square one (first one mentioned above), you need to use if-else statements and manually set the color.  For the second one, you can change the color by setting it to a variable's number.

Also, when I said "set color to [green]", that was using the color-square-block.  I don't know how to put in actual colors with the scratch blocks  smile

oh ok!
(Should i give credit to you?)

Last edited by coolhogs (2012-02-24 23:12:23)


Get ready for domination of:  tongue

Offline

 

#20 2012-02-25 09:06:49

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

Re: How to make a list go back through itself!

I don't think that's necessary in this case.  I didn't really give you a concrete script, and, if you use the second method, all I did was point you to a block.


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

Offline

 

#21 2012-02-25 10:58:52

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

I tried using MoreGamesNow's script with his/her's block
Here is the result http://scratch.mit.edu/projects/coolhogs/2355713 It won't work. Can anyone fix it for me?


Get ready for domination of:  tongue

Offline

 

#22 2012-02-25 13:28:42

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

Re: How to make a list go back through itself!

Here you go.


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

Offline

 

#23 2012-02-25 15:51:24

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: How to make a list go back through itself!

MoreGamesNow wrote:

Here you go.

Thanks, I had to change some things!


Get ready for domination of:  tongue

Offline

 

Board footer