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

#1 2012-04-02 21:45:42

Seymorevenue
New Scratcher
Registered: 2012-04-02
Posts: 3

Help With List

I was wondering if i could use lists to hold all skills in a game. I've been trying to say if any of the conditional variables in the list are true then do something. Eg. punch=z pressed?
But it doesnt add to the list.

Offline

 

#2 2012-04-03 05:21:47

analytic
New Scratcher
Registered: 2012-02-20
Posts: 90

Re: Help With List

Could you please explain in more detail what you are trying to accomplish with lists?

Offline

 

#3 2012-04-03 06:04:16

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Help With List

Of course you can do that!

when gf clicked
replace item (1 v) of [list v] with <key [z v] pressed?>
...
if <(item (1 v) of [list v]) = [true]>
say [z is pressed]
end


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4 2012-04-03 09:30:16

Seymorevenue
New Scratcher
Registered: 2012-04-02
Posts: 3

Re: Help With List

[scratchblocks]
when gf clicked
delete (all) of skills

Offline

 

#5 2012-04-04 09:25:25

Seymorevenue
New Scratcher
Registered: 2012-04-02
Posts: 3

Re: Help With List

Woops, i lost internet right before my last post. I still havent been able to do what you showed hardmath. i dont recognize the ... block if that does anything.

My Code:

when gf clicked 
add [(key [z] pressed?)] to [skills]
if (item (any) of [skills] = [true])
say [z is pressed]
This is just a test to see if it will add key z pressed to skills, and it doesnt work. what i actually am aiming to do is if any skills are true then execute a series of if then statements for each skill. Im not sure whats wrong.

P.S. how do i preview my post to check if i got the scratchblocks right?

Offline

 

#6 2012-04-04 11:23:29

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Help With List

First of all, the [...] block does nothing, in fact it doesn't exist. I put it there to indicate "put some more blocks here, it doesn't matter what".

To preview your post, you need to click on the "Post Reply" link above the Quick Post box, to the right (right under the last post's report button). In the new editor, you will have a 'Preview' option.

Finally, your question. Here is what you need to do, I think:

when gf clicked
replace item (1 v) of [skills v] with <key [z v] pressed?>
replace item (2 v) of [skills v] with <key [x v] pressed?>
if <(item (1 v) of [skills v]) = [true]>
say [z was pressed]
end
if <(item (2 v) of [skills v]) = [true]>
say [x was pressed]
end


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#7 2012-04-06 23:16:01

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Help With List

If you need any explanation on Lists, check out the Scratch Wiki @ http://wiki.scratch.mit.edu/wiki/List.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#8 2012-04-08 14:50:13

PencilFactory
Scratcher
Registered: 2011-11-11
Posts: 100+

Re: Help With List

Hardmath123 wrote:

First of all, the [...] block does nothing, in fact it doesn't exist. I put it there to indicate "put some more blocks here, it doesn't matter what".

To preview your post, you need to click on the "Post Reply" link above the Quick Post box, to the right (right under the last post's report button). In the new editor, you will have a 'Preview' option.

Finally, your question. Here is what you need to do, I think:

replace item (1 v) of skills with <key (z v) pressed?>
if <(item [1 v] of [skills v]) = (1) >
something
end

not << (item (1 v) of skills) = [true] >>

Last edited by PencilFactory (2012-04-08 14:53:54)


PencilFactory is http://blocks.scratchr.org/API.php?user=PencilFactory&amp;action=onlineStatus&amp;type=text, see my computerhttp://mag.racked.eu/cimage/i9002/Achievement+get%21/Computer+crashed/mca.png

Offline

 

#9 2012-04-08 15:26:02

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: Help With List

PencilFactory wrote:

Hardmath123 wrote:

First of all, the [...] block does nothing, in fact it doesn't exist. I put it there to indicate "put some more blocks here, it doesn't matter what".

To preview your post, you need to click on the "Post Reply" link above the Quick Post box, to the right (right under the last post's report button). In the new editor, you will have a 'Preview' option.

Finally, your question. Here is what you need to do, I think:

replace item (1 v) of [skills v] with <key [z v] pressed?>
if <(item (1 v) of [skills v]) = [true] >
something
end

<not < (item (1 v) of [skills v]) = [true] >>

Scripts fixed by: TorbyFork234

Offline

 

Board footer