Results 1 to 8 of 8

Thread: Persistent GUIDs for cards

  1. #1
    Join Date
    Jan 2017
    Location
    England
    Posts
    8

    Persistent GUIDs for cards

    I am creating a card game, for which I need the script to be aware of the value of the cards.

    I copied all of the GUIDs of the cards and put them in a table with all the correct values, then I clicked save and play, and all the GUIDs for the cards were different.

    Is there any way to make the GUIDs of the cards stay the same? The deck always has the same GUID, but not the cards.

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    Not reliably. Instead, name the cards and equate the name to a value. You can turn off the tooltips on the card if you dont want them poking up.

  3. #3
    Join Date
    Jan 2017
    Location
    England
    Posts
    8
    Quote Originally Posted by MrStump View Post
    Not reliably. Instead, name the cards and equate the name to a value. You can turn off the tooltips on the card if you dont want them poking up.
    I suspected as much. However, the name and description fields of the cards are greyed out. Is there some JSON file I can edit, or any way to unlock the cards so I can give them a name? I'm using decks that have been made by someone else.

  4. #4
    Join Date
    Jan 2017
    Location
    England
    Posts
    8
    Nevermind I found a solution.

    If you go into the save file for the game, all the cards have:
    "GUID": ""
    I changed all the cards GUIDs individually, and now they stay the same!
    Of course I made sure they were all distinct but I really just went up from 000000.

    Not sure if this is undefined behaviour, but this is the solution I will use.

  5. #5
    Join Date
    May 2016
    Posts
    1,072
    That is 1 solution. As for the greying out, you didn't notice because you had 2 sided cards. When they are "face down" the name greys out. This is to stop you from reading, say, playing card values when they are face down. I think the behavior persists when double-sided with unique backs.

    The script can read the name when it is in a deck or face down, so it won't get in the way of the script. But as long as you found a solution that works, good on ya.

  6. #6
    Is that the best way to assign values to cards? Via Name? Is there any way to add fields to the objects in game without resorting to GUIDs?

  7. #7
    Join Date
    May 2016
    Posts
    1,072
    There's a few ways. One, you can put a simple piece of script on each card like: value = "Whatever"

    And then read the value from the scripts. I personally dislike this method. What I prefer is to put names onto each card, keep a table with those names in it in the script that I can use to assign value. No GUIDs required, just get the name off a card and check that name against the value table.

    Additionally, if you knew certain cards in certain locations were to have X value, you could use a script zone and setVar on the card to apply a value, but that won't naturally persist through undo/load so this is a very niche solution.

  8. #8
    Keep in mind that setVar() does not persist through saving and loading! If it's critical that the values are remembered when saving and then loading the game, you need to store the values elsewhere.

    Specifying the GUIDs is a pretty solid way, if the data's static.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •