# Question about .json item groups

**URL:** <https://discourse.cataclysmdda.org/t/question-about-json-item-groups/9956>\
**Category:** The Toolbox\
**Created:** [June 29, 2015, 7:04pm UTC](https://discourse.cataclysmdda.org/t/question-about-json-item-groups/9956 "2015-06-29T19:04:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunshine](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sunshine](https://discourse.cataclysmdda.org/u/Sunshine)\
**Post date:** [June 29, 2015, 7:04pm UTC](https://discourse.cataclysmdda.org/t/question-about-json-item-groups/9956/1 "2015-06-29T19:04:55Z")

</div>

I have a quick question about item groups. Is there a way to have a reference to another item group within a list of items. For example this:

`
{
    "type" : "item_group",
    "id" : "forest",
    "items":[
      ["rock", 40],
      ["stick", 95],
      ["pine_bough", 15],
      ["acorns", 15],
      ["pinecone", 5],
      ["one_year_old_newspaper", 2],
      ["months_old_newspaper", 3],
      ["weeks_old_newspaper", 4],
      ["newest_newspaper", 5],
      ["bottle_plastic", 1],
      ["bottle_glass", 1],
      ["syringe", 1],
      ["cig_butt", 1]
    ]
  }`  
…could be changed to something like this:

`
{
    "type" : "item_group",
    "id" : "forest",
    "items":[
      ["rock", 40],
      ["stick", 95],
      ["pine_bough", 15],
      ["acorns", 15],
      ["pinecone", 5],
      ["ITEM_GROUP":"trash", 5]
    ]
  }`  
Or something like that.

Basically a way to nest smaller, more focused item groups in larger ones.

---

<div class="post-metadata">

**Author:** ![Sunshine](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sunshine](https://discourse.cataclysmdda.org/u/Sunshine)\
**Post date:** [July 2, 2015, 9:05pm UTC](https://discourse.cataclysmdda.org/t/question-about-json-item-groups/9956/2 "2015-07-02T21:05:00Z")

</div>

I see that you can set a point and set a line, but is in there a way to set an area or fill a rectangle with terrain?

This works, but it seems kinda crappy.

> "place\_terrain": [{ "x": [ 12, 22], "y": [7, 14], "ter": "t\_concrete", "repeat": 999 } ],

---

<div class="post-metadata">

**Author:** ![vache](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@vache](https://discourse.cataclysmdda.org/u/vache)\
**Post date:** [July 2, 2015, 11:17pm UTC](https://discourse.cataclysmdda.org/t/question-about-json-item-groups/9956/3 "2015-07-02T23:17:30Z")

</div>

It looks like json has some support for using “square” instead of “set”, but I can’t find it mentioned except but for a couple places in the code. I don’t have my IDE right now though, just going off of github.

---

<div class="post-metadata">

**Author:** ![BevapDin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/bevapdin/32/228_2.png) [@BevapDin](https://discourse.cataclysmdda.org/u/BevapDin)\
**Post date:** [July 3, 2015, 11:41am UTC](https://discourse.cataclysmdda.org/t/question-about-json-item-groups/9956/4 "2015-07-03T11:41:09Z")

</div>

I wonder why people even bother to write documentation when apparently nobody reads them.

> Basically a way to nest smaller, more focused item groups in larger ones.

Yes, and if you had looked at data/json/item\_groups.json carefully (hint: search for “group” - with the [tt]"[/tt]), you would have found the item group “forage\_summer” (search for it). It contains an example of what you want. Btw. the documentation for item groups is in doc/ITEM\_SPAWN.md

> I see that you can set a point and set a line, but is in there a way to set an area or fill a rectangle with terrain?

From doc/MAPGEN.md:

> ### 2.3.2 "square" \*\*required\*\* Define a square of things. Requires "x", "y", "x2", "y2", "id" (or "amount" for "radiation") \> Value: "terrain", "furniture", "trap", "radiation"
> 
> Example: { “square”: “radiation”, “amount”: 10, “x:” [0, 5], “y”: [0, 5], “x2”: [18, 23], “y2”: [18, 23] }  
> The arguments are exactly the same as “line”, but “x”, “y” and “x2”, “y2” define opposite corners

Apparently this is currently not used in any mapgen, so no actual example.

However, why don’t you the other mapgen system where you draw a map in ASCII and link the characters to the furniture/items/terrain etc. - see data/json/mapgen/museum.json for an example. That format is far easier to read and understand than using explicit coordinates.

---

<div class="post-metadata">

**Author:** ![Sunshine](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sunshine](https://discourse.cataclysmdda.org/u/Sunshine)\
**Post date:** [July 5, 2015, 11:41pm UTC](https://discourse.cataclysmdda.org/t/question-about-json-item-groups/9956/5 "2015-07-05T23:41:36Z")

</div>

> [@BevapDin](#):
>
> I wonder why people even bother to write documentation when apparently nobody reads them.

I didn’t read them because I didn’t even know they existed. Thanks for pointing those out. I was looking through the game files not on the git.

[quote=“BevapDin, post:4, topic:9956”]\> Basically a way to nest smaller, more focused item groups in larger ones.

Yes, and if you had looked at data/json/item\_groups.json carefully (hint: search for “group” - with the [tt]"[/tt]), you would have found the item group “forage\_summer” (search for it). It contains an example of what you want. Btw. the documentation for item groups is in doc/ITEM\_SPAWN.md

> I see that you can set a point and set a line, but is in there a way to set an area or fill a rectangle with terrain?

From doc/MAPGEN.md:

> ### 2.3.2 "square" \*\*required\*\* Define a square of things. Requires "x", "y", "x2", "y2", "id" (or "amount" for "radiation") \> Value: "terrain", "furniture", "trap", "radiation"
> 
> Example: { “square”: “radiation”, “amount”: 10, “x:” [0, 5], “y”: [0, 5], “x2”: [18, 23], “y2”: [18, 23] }  
> The arguments are exactly the same as “line”, but “x”, “y” and “x2”, “y2” define opposite corners

Apparently this is currently not used in any mapgen, so no actual example.

However, why don’t you the other mapgen system where you draw a map in ASCII and link the characters to the furniture/items/terrain etc. - see data/json/mapgen/museum.json for an example. That format is far easier to read and understand than using explicit coordinates.[/quote]

Awesome. Thanks.

I can’t use the ASCII method easily because I want several rooms on the same map with different floors but the same type furniture. And it would be weird if a player moved a dresser to find a different color of carpet from the rest of the room.
