Discuss Scratch

Lankybox123
Scratcher
42 posts

Picking a Character only once

Hey guys I'm kind of having trouble on my project so it would mean a lot to me if you could help. Thx! So I am making a game right now and it is requiring to pick different characters. I have different ones but I did a picking random code that will pick a random character for the scratcher that is playing to use. I want to make it so that the character that has already picked once will not be picked again. I don't know how this will work so I am hoping that one of you could help me. Tysm I really appreciate it!
deck26
Scratcher
1000+ posts

Picking a Character only once

Is this multiplayer? We had a recent topic on something very like this.
Cutie_Pooge
Scratcher
500+ posts

Picking a Character only once

set [characterNumber v] to (pick random (1) to (6)) //replace 6 with amount of characters
if <[pickedCharacters v] contains (character) ?> then
repeat until <not <[pickedCharacters v] contains (character) ?>>
set [characterNumber v] to (pick random (1) to (6)) //replace 6 with amount of characters
end
end
add (characterNumber) to [pickedCharacters v]
This has not been tested, if the player has already chosen all the characters, the block will go forever. This is a simple ineffcient solution.

Last edited by Cutie_Pooge (July 10, 2020 14:28:12)

Oumuamua
Scratcher
1000+ posts

Picking a Character only once



Last edited by Oumuamua (July 10, 2020 15:45:21)

Lankybox123
Scratcher
42 posts

Picking a Character only once

Wow tysm guys! This really means a lot to me! I really appreciate it! __

Powered by DjangoBB