Aid with structures

Hello. I’m working on expanding factions, but I have experienced some code error. I could use some help with this.

[
{
“type”: “mapgen”,
“method”: “json”,
“om_terrain”: [ “survivor_campsite” ],
“weight”: 500,
“object”: {
“rows”: [
“…”,
“…”,
“…”,
“…”,
“.mm.mm…##########…”,
“.mm.mm…#33’’’’’’#…”,
“.mm.mm…#33’’’’’’#…”,
“.mm.mm…#’’’’’’’’#…”,
“.mm.mm…#’’’’’’’’#2…”,
“.mm.mm…#’’’’’’’’#O…”,
“.mm.mm…#’’’’’’’’#=…”,
“.mm.mm…#’’’’’’’’#U…”,
“…#####++###…”,
“…”,
“…”,
“…-r-…”,
“…-r-…”,
“…”,
“…-r-…t…t…”,
“…-r-…t…”,
“…”,
“…”,
“…”,
“…”
],
“terrain”: {
“m”: “t_dirtmound”,
“’”: “t_grass”,
“+”: “t_grass”,
“-”: “t_dirt”,
“.”: [ “t_grass”, “t_grass”, “t_grass”, “t_grass”, “t_grass”, “t_dirt” ],
“b”: “t_dirt”,
“d”: “t_dirt”,
“r”: “t_dirt”,
“t”: “t_tree”
},
“furniture”: {
“#”: “f_canvas_wall”,
“’”: “f_groundsheet”,
“+”: “f_canvas_door”,
“-”: “f_camp_chair”,
“b”: “f_firering”,
“r”: “f_tourist_table”,
“U”: “f_kiln_empty”,
“=”: “f_smoking_rack”,
“O”: “f_fvat_empty”,
“2”: “f_butcher_rack”,
“3”: “f_bed”
},
“place_items”: [
{ “item”: “cannedfood”, “x”: [ 12, 4 ], “y”: [ 21, 7 ], “chance”: 75 },
{ “item”: “cannedfood”, “x”: [ 16, 4 ], “y”: [ 21, 7 ], “chance”: 75 },
{ “item”: “pasta”, “x”: [ 16, 4 ], “y”: [ 21, 7 ], “chance”: 75 },
{ “item”: “camping”, “x”: [ 10, 8 ], “y”: [ 15, 13 ], “chance”: 75 }
]

Well, your rows all need to have the same number of characters (and it has to be a multiple of 24).
But it’s impossible to help if you don’t give the errors you’re getting.

src/main_menu.cpp:735 [bool main_menu::new_character_tab()] Error: data/mods//Expanded Factions/survivor_campsite.json: EOF: expecting string but found ‘:’

You need to close the object and array there too, add } ] (spaced correctly) to the end of the file.

What do you mean by “close the object and array”?

In JSON, {} specifies and object, and [] an array.
Every object or array that is opened (has an opening {/[) must be closed (have a corresponding }/]).
At the start of that, you open an array, and an object, but do not close them.

I have also received errors that state: src/main_menu.cpp:735 [bool main_menu::new_character_tab()] Error: data/mods//Expanded Factions/survivor_campsite.json: line 33:10: expecting string but found ‘[’

    "........................",

    "........................"

  ], [
     ^
       {

10 “terrain”:
10 “m”:“t_dirtmound”,
10
21:39:10.527 : Log shutdown.

What is the meaning of “string”?

A string is generally text, but it’s just anything enclosed in quotes.
These are all strings:
"cats"
" "
""
".........................."

I’d suggest you look at how other mapgen is done, and try to format your files like that.

Okay, I do appreciate all of your aid with this project.

Also consider reading the Guide for 1st time contributors which includes a brief introduction to JSON and mapgen.

1 Like

Oh, you’re using the incorrect quotation mark characters, which the JSON reader doesn’t recognize.
and instead of ". What are you using to edit this?
Here’s a corrected version

[
  {
    "type": "mapgen",
    "method": "json",
    "om_terrain": [ "survivor_campsite" ],
    "weight": 500,
    "object": {
      "rows": [
        "…",
        "…",
        "…",
        "…",
        ".mm.mm…##########…",
        ".mm.mm…#33’’’’’’#…",
        ".mm.mm…#33’’’’’’#…",
        ".mm.mm…#’’’’’’’’#…",
        ".mm.mm…#’’’’’’’’#2…",
        ".mm.mm…#’’’’’’’’#O…",
        ".mm.mm…#’’’’’’’’#=…",
        ".mm.mm…#’’’’’’’’#U…",
        "…#####++###…",
        "…",
        "…",
        "…-r-…",
        "…-r-…",
        "…",
        "…-r-…t…t…",
        "…-r-…t…",
        "…",
        "…",
        "…",
        "…"
      ],
      "terrain": {
        "m": "t_dirtmound",
        "’": "t_grass",
        "+": "t_grass",
        "-": "t_dirt",
        ".": "t_grass",
        "b": "t_dirt",
        "d": "t_dirt",
        "r": "t_dirt",
        "t": "t_tree"
      },
      "furniture": {
        "#": "f_canvas_wall",
        "’": "f_groundsheet",
        "+": "f_canvas_door",
        "-": "f_camp_chair",
        "b": "f_firering",
        "r": "f_tourist_table",
        "U": "f_kiln_empty",
        "=": "f_smoking_rack",
        "O": "f_fvat_empty",
        "2": "f_butcher_rack",
        "3": "f_bed"
      }
    }
  }
]
1 Like

Thank you!

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa