I'm working on a solitaire level editor. ChatGPT has been a TREMENDOUS help on this project but we're stuck on something that I thought would be fairly simple. I'm hoping one of you experts can help!
What I'm Trying to Do:
When I SAVE my layout I want to iterate through all the cards and, using zIndex, figure out which cards are Covering and which cards are CoveredBy the current card. These will then get saved in instance variables, like this:
card_spr.Covering = "3, 5, 7" (this card is covering cards 3, 5, and 7)
card_spr.CoveredBy = "" (this card isn't covered by any cards)
ChatGPT suggested that I create 2 families with spr_card as the only member. fam_cards has all the instance variables. fam_cards2 is for the inner loop.
This was working, but I stupidly used Construct 3's UID in my events. This doesn't work for SAVING and LOADING, so I created a new instance variable: fam_cards.CardID and I increment this every time I create a new sprite. (It gets saved with the level.)
But if I put CardID in the sprite my families can't access it. And if I put it in fam_cards.CardID then I can't reach it with fam_cards2.CardID.
Any suggestions? Is there an easier way to do this?
Code Before I made my own "CardID"
+ System: For each fam_cards
-> fam_cards: Set Covering to ""
-> fam_cards: Set CoveredBy to ""
----+ System: For each fam_cards2
--------+ fam_cards2: Is overlapping fam_cards
------------+ System: fam_cards2.ZIndex < fam_cards.ZIndex
-------------> fam_cards: Set Covering to fam_cards.Covering & fam_cards2.UID & ","
------------+ System: Else
-------------> fam_cards: Set CoveredBy to fam_cards.CoveredBy & fam_cards2.UID & ","