Help with random card selector

I am trying to create a game where each player is dealt 2 cards. I am aware of how to do this, but currently it would take 4 triggers, each with blocks, to do this for every card the players will be dealt. Hereโ€™s what it would look like with my system.


and at the end it would set a property to the card that was selected. This would also trigger a different chain of triggers to select the second card for the players and so on. I was wondering if there was any way I could make this more efficient, both saving time and memory.

1 Like

Can you send the text of the cards used? I have an idea, but Iโ€™ll need them first.

1 Like

Maybe instead of setting a variable to the card, just set the property to the card from the beginning.

Yeah
๐Ÿ‚ก๐Ÿ‚ข๐Ÿ‚ฃ๐Ÿ‚ค๐Ÿ‚ฅ๐Ÿ‚ฆ๐Ÿ‚ง๐Ÿ‚จ๐Ÿ‚ฉ๐Ÿ‚ช๐Ÿ‚ซ๐Ÿ‚ญ๐Ÿ‚ฎ

๐Ÿ‚ฑ๐Ÿ‚ฒ๐Ÿ‚ณ๐Ÿ‚ด๐Ÿ‚ต๐Ÿ‚ถ๐Ÿ‚ท๐Ÿ‚ธ๐Ÿ‚น๐Ÿ‚บ๐Ÿ‚ป๐Ÿ‚ฝ๐Ÿ‚พ

๐Ÿƒ๐Ÿƒ‚๐Ÿƒƒ๐Ÿƒ„๐Ÿƒ…๐Ÿƒ†๐Ÿƒ‡๐Ÿƒˆ๐Ÿƒ‰๐ŸƒŠ๐Ÿƒ‹๐Ÿƒ๐ŸƒŽ

๐Ÿƒ‘๐Ÿƒ’๐Ÿƒ“๐Ÿƒ”๐Ÿƒ•๐Ÿƒ–๐Ÿƒ—๐Ÿƒ˜๐Ÿƒ™๐Ÿƒš๐Ÿƒ›๐Ÿƒ๐Ÿƒž

1 Like

You could have a property that stores all of the cards in the beginning, and then you use the sub string block to grab the selected letter from the card text string. Does that make sense?

Are the cards like emojis or something?

No, special characters

So, because all of the text is the same length of 2, you can use text strings.

Combine all of the cards into a single text block and do this:

This will retrieve the randomly selected card from the string of text. You could also use a property that holds all of the cards, and when a player draws that card, it could be removed from the property to ensure that nobody else gets the same card.

1 Like

This could cause a range error if the random number selected is greater than the total number of cards remaining in the deck.

Instead of just having the random number being from 1 to 52, have it be from 1 to len(cards), cards being the property storing the remaining cards in the deck.

Are the cards not one character each? Why do we need to multiply our random number? In fact, the substring doesnโ€™t need to use math, just get the character in the string with the index of the random number that was generated.

Otherwise, this is the solution to your problem!

Correction:

4 Likes

And I can just repeat this, changing the variable for the other cards?

Yeah it should, if you need more help, let me know. I also made a system for if you want it to where you canโ€™t get the same card more than once:

The property cards is a globally scoped text property.

2 Likes

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.