Multiple values in properties?

35 views
Skip to first unread message

Rastayeti666

unread,
Jan 12, 2019, 1:56:19 AM1/12/19
to idle_...@googlegroups.com
hey guys,

in my selfmade game system i have different armor for zones and different armor types. types are for example physical, fire, magic and zones are chest, head and limps.

my question, is there are possibility to store multiple values in properties, for example "armor chest: 3,1,1" for 3 physical, 1fire and 1 magic?

i think there could be a way with json, but i couldnt make it work or even bring the values in the macro in a way i could use them

Idle Ideas Inc.

unread,
Jan 14, 2019, 3:47:07 AM1/14/19
to Home of our Idle Ideas
json can handle this. you just have to nest your data properly. You can either do JSON object within a JSON object, or JSON array within a JSON object.

Nested JSON Object sample:
{
  "armor" : {
          "chest": { 
          "physical": 3,
          "fire": 1,
          "magic": 1
      }
  }
}

JSON array within JSON object (you do this when you are aware of what array index pertains to what information e.g. 0 for physical, 1 for fire and 2 for magic):

{
  "chest armor": [3, 1, 1]
}

or 

{
  "armor" : {
          "chest": [3, 1, 1]
      }
  }
}

Try to structure your data to avoid deep nesting. At best, keep it to 1 to 2 levels deep. Also use the JSON api, whenever possible, as opposed to manually writing JSON yourself. But if you have to write JSON manually, make sure to run what you make by a JSON validator / linter such as the one found online here.

HTH.

Rastayeti666

unread,
Jan 14, 2019, 12:49:18 PM1/14/19
to idle_...@googlegroups.com
in a macro itself i could make it work before, but is there a possibility to add these values in properties and get them from there (like in this example "chest": [3, 1, 1])? i would like to use the properties to make it clearer instead of hiding armor values in certain macros

Idle Ideas Inc.

unread,
Jan 15, 2019, 3:40:21 AM1/15/19
to Home of our Idle Ideas
What kind of properties do you mean? Campaign properties? Token properties? Either one could hold such values; the former as a default value, or the latter, as a property value specific to the token. You can even directly enter it when using the Edit Token Dialog, just make sure the token is using an actual set of token properties (this is at the last tab of the token editor). 

There is also saving values in libraries (lib tokens) or using the SQL feature.

Rastayeti666

unread,
Jan 15, 2019, 11:26:22 AM1/15/19
to Home of our Idle Ideas
okay , here things goes way beyond my knowledge :D i want to write the values in every different tokenin the properties, for example

armor (head): 3,1,1

how exactly is the format i must write in the properties? with brackets? without? are commas usable? etc

how do i get the values in my macro? run.expression(string(propertyName))? getproperty?

and how exactly do i embed this command in the macro

a working example would be really appreciate to understand the logic and the format for it

sry for asking for so much trouble, but i tried to get the values from the properties in the macro before but never got it to work besides simple dice rolls like 1d6

Idle Ideas Inc.

unread,
Jan 16, 2019, 3:15:43 AM1/16/19
to Home of our Idle Ideas
The JSON examples I gave above are the basic format to define the data structures you need. Try to read up on JSON to grasp the basic concepts of what JSON object and array is :)

It's never advisable to manually manipulate your data. Instead, use the scripting API to do this for you.

But from what I understand right now about what want to do, you're more concerned with representing these values, as opposed to manipulating them within your game, am I correct?

If so, you don't necessarily need to use JSON. JSON works best for when you need to represent a collection or map of properties or values.

If your list of stats isn't that particularly long, why not just represent every stat and sub-stat in a 1:1 manner?

For example: 
head armor vs. physical attack = 3
head armor vs. magical attack = 1
etc etc.

Of course you can shorten your keys (e.g. head armor vs. physical attack) into an acronym like HAVPA or anything you'd like. Then you can use the property name in-game, to pull up its associated value

Due to existing constraints, we don't usually help much in writing macros, as there too many ways to write them, and we restrict ourselves to helping out with users write themselves. I hope you understand.
Reply all
Reply to author
Forward
0 new messages