Search Unity

Question Multiple parameters on the same line of custom data?

Discussion in 'Economy' started by Corva-Nocta, Apr 29, 2023.

  1. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    Hey all, quick small question: when setting up custom data for an item, is it possible to have multiple values for a single entry? For example: if I have a sword and I want to set a minimum damage value and maximum damage value, can I store that as a single variable "damage" with 2 numbers, or do I need to make that 2 different variables?

    Can I write something like this:
    Code (csharp):
    1. {
    2.    "Damage": 2, 3
    3. }
    Obviously the syntaxes would be different, but I'm not sure what that syntax would be

    or is it only possible to do
    Code (csharp):
    1. {
    2.    "minDmg": 2,
    3.    "maxDmg": 3
    4. }
     
  2. Shaun-Peoples

    Shaun-Peoples

    Joined:
    Feb 26, 2013
    Posts:
    24
    Your first example is invalid JSON. As long as you enter valid JSON, you can effectively store whatever you like. If you change your first example to an array format, it will work:

    Code (JavaScript):
    1. {
    2.     "Damage": [2, 3]
    3. }
    The resource creation JSON editor validates as you enter inputs, so it should give you a good idea of what is allowable.