How to select something specific from an array?

I made this very simple base for a card game called “Spades” but I can’t select a specific card / also can’t figure it out. Could @WoofWoof or really anyone else help me out?
Press LMB to change turns and place a card into the middle onto the plate.

2 Likes

Use a “get value from” block. The number specifies the item from the array of your choice.

You could use a variable to select a specific value from an array and then remove it via it’s index.

Updated link!

Could I get a specific example? I understand the basics of what you’re saying but I don’t know how to execute that

what i like to do is use the extension Sprite Data (you can find it in the default list). When creating the cards, set a number value for each one, corresponding to their order (1 - 7). Set up another sprite data for what player the card belongs to (1 or 2)

Make a variable called selection
when pressing L or R, change this variable by 1 or -1 (also make sure that you cant make the number -1 or greater than 6) This is the number that will correspond to the selected card.

Make a function to visually update the given sprite. This will be the updated form of the selected card. Make sure you code in the unselection of any previously selected cards as well.
To obtain the correct sprite input, use the get value from array of the card sprite kinds. This will run through every single card. But by setting an if statement to sort for the card data that = the selection variable, we only get 1 card. This one card is the “selected” card who’s card data corresponds to the “selection” variable.


(here i just increased the scale and the z value to make it larger and appear on top of other cards)

Bringing it together, place the function in the on L and R press.

this is actually descibing how i coded the card selection for Card Delver lmao so PLS do not copy the code exactly with the values as it is not going to translate 1 to 1

3 Likes

Thanks to @Luke I have a (mostly) working card selection setup! I haven’t actually made the logic behind putting a card into the middle, but I now need help with a new issue… I can’t seem to remove the card from being “highlighted”. Can someone help me again?

1 Like

yay congrats! Another thing you can do with sprite data is store what type of card you are using. So I like to store the original card image and retrieve it when i need to use it to reset the selected card back to normal.

if that doesn’t apply feel free to tell me more about how you made the card “selected” that would be super helpful.

1 Like

Sure! Here is a few screen shots and the game

Woah thanks! This is just what I needed! I appreciate you taking the time to make this for me

1 Like

kinda off topic but I love the new flow of card games

1 Like