Discuss Scratch

Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Is there any way to set a variable to the costume name of an object?
deck26
Scratcher
1000+ posts

Is there any way to set a variable to the costume name of an object?

([costume name v] of [spritename  v])
Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

How can I set a variable to a random costume?
P444
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Name doesn't matter, it will switch to the costume number.
set [var v] to (pick random (1) to (10))
switch costume to (var)
deck26
Scratcher
1000+ posts

Is there any way to set a variable to the costume name of an object?

P444 wrote:

Name doesn't matter, it will switch to the costume number.
set [var v] to (pick random (1) to (10))
switch costume to (var)
or combine to a single block

switch costume to (pick random (1) to (10))  //change 10 to number of costumes

I'd advise against using numbers as costume names - that's not what's being suggested.
Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

No, I want that the variable will display a random name of a costume.
deck26
Scratcher
1000+ posts

Is there any way to set a variable to the costume name of an object?

Scratch739201 wrote:

No, I want that the variable will display a random name of a costume.
Answered in your other topic. Please try to avoid duplicate topics, it just gets confusing!
P444
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Use a list. You have to match each costume number and name with each item number and item in the list. Then do this:
switch costume to (pick random (1) to (10))
say (item (costume #) of [names v]) for (2) secs
//or
set [var v] to (item (costume #) of [names v]

Edit: Ok *facepalm* , so which topic is legit?

Last edited by P444 (March 18, 2016 19:43:22)

Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

How can I do this with 192 costumes?
reefphp
Scratcher
8 posts

Is there any way to set a variable to the costume name of an object?

P444 wrote:

Name doesn't matter, it will switch to the costume number.
set [var v] to (pick random (1) to (10))
switch costume to (var)
Using this method, you could use two variables:

set [costume v] to (var)
P444
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Are they numbered costumes(like gif1, gif2. gif3)? Or 192 unique names(help)(walk)(stand still)?
If it's the first one, it'd be a bit easier (ok, a lot easier) than adding all different costume names to a list.
If it is the first one, you can simply do this:
set [count v] to [0]
repeat (192)

change [count v] by (1)
add (join [all_characters_before_number_] (count)) to [names v]
end
P444
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Also, it's be easier if you could share the project (and a link to it) so it'll be easier for us to help you.
Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Also, I tried it but it doesn't work correctly.

See this: https://scratch.mit.edu/projects/102283452/
P444
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Scratch739201 wrote:

Also, I tried it but it doesn't work correctly.

See this: https://scratch.mit.edu/projects/102283452/
Not shared…

Yay, finally ninjaed someone by 1 second!!

Last edited by P444 (March 18, 2016 20:04:08)

Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

P444 wrote:

Are they numbered costumes(like gif1, gif2. gif3)? Or 192 unique names(help)(walk)(stand still)?
If it's the first one, it'd be a bit easier (ok, a lot easier) than adding all different costume names to a list.
If it is the first one, you can simply do this:
set [count v] to [0]
repeat (192)

change [count v] by (1)
add (join [all_characters_before_number_] (count)) to [names v]
end
I don't use numbered costumes. Just different names.
Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

deck26
Scratcher
1000+ posts

Is there any way to set a variable to the costume name of an object?

Just get the sprite to build the list. Set it to the first costume, add to an empty list, change costume, add to list etc.
P444
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

You should use the backdrop as it allows the name of the backdrop to be read. Though you can't move it anyway.
Scratch739201
Scratcher
500+ posts

Is there any way to set a variable to the costume name of an object?

Why is this still not working correct? https://scratch.mit.edu/projects/102283452
deck26
Scratcher
1000+ posts

Is there any way to set a variable to the costume name of an object?

See my remix https://scratch.mit.edu/projects/102287483/

The trick is to copy the sensing block from another sprite or the stage and you can then access the costume name of the sprite.

Powered by DjangoBB