I need different ways to use the dictionary to store unique values for each object in a family

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • The only way I've been able to do is

    But I need at least one more way to do a number value. Anyone got anything?

  • That sounds fine to have a value per type in the family. If you wanted a value per instance you could use cards.uid as the key.

    If you wanted multiple values per type or instance you could just use another dictionary or append something like “:value1” to the key or something. For example cards.uid&“:value1”

  • Consider using JSON instead, you can store any amount of data for each card. For example:

    CardJSON set path to CardName
    CardJSON set ".quantity" to (CardJSON.get(".quantity")+1)
    CardJSON set ".price" to 500
    

    To retrieve a value: CardJSON.get(CardName & ".price")

  • That sounds fine to have a value per type in the family. If you wanted a value per instance you could use cards.uid as the key.

    If you wanted multiple values per type or instance you could just use another dictionary or append something like “:value1” to the key or something. For example cards.uid&“:value1”

    Unfortunately UID is itself a number. The key for a dictionary can't be a number.

  • Consider using JSON instead, you can store any amount of data for each card. For example:

    > CardJSON set path to CardName
    CardJSON set ".quantity" to (CardJSON.get(".quantity")+1)
    CardJSON set ".price" to 500
    

    To retrieve a value: CardJSON.get(CardName & ".price")

    idk, I use Construct explicitly when I don't feel like coding, I don't think there was any other ways to do JSONs unless I'm just blind.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just make the number a string with str().

    I don’t understand the statement about json. It’s a plugin you can use.

  • idk, I use Construct explicitly when I don't feel like coding, I don't think there was any other ways to do JSONs unless I'm just blind.

    Think of JSON as a more advanced and flexible dictionary. It's not that complicated once you try it.

    You can of course use a dictionary. There are two options:

    1. Name the keys in the dictionary as CardType&ValueType, for example "DarkKnight_price":10

    2. Create a new instance of the dictionary for each instance of the card sprite. Link it with the card (for example, by UID). Then each card will have its own dictionary.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)