Trying to add a new building into game and met an error

Greetings! I have a problem: when I try to add a new building into game, it shows me debug message:

Error: Tried to generate map for omtype intcafe_east, "cyber cafe" (id_mapgen intcafe)

The building itself does not spawn in its place, there is only a empty floor instead.

What am I doing wrong?

What does your json look like?

This json itself:

[spoiler][
{
“type”: “mapgen”,
“om_terrain”: [
“intcafe”
],
“method”: “json”,
“weight”: 500,
“object”: {
“rows”: [
"",
"
",
"|-000000–|:|-000000-|",
"|y…r…#.ydddd|",
0%…%…%…%h…hd0”,
0dh.dh.dh…#…d0”,
0…%h…0”,
0%…%…%…######.0”,
0dh.dh.dh…0”,
"|…y|",
"|%…%…%…|±|±|",
0dh.dh.dh…|.D|.D|”,
0…|.s|.s|”,
0…|±|±|”,
"|y…y|.t|.t|",
"|------±------------|",
"|[[FD…]|%%%%%%%|$.r|",
"|h…]|…|Z.r|",
0…]|-±----|Z.r|”,
0d%d…+…i…r|”,
"|dh…y|y???[y|…r|",
"|—00------00-------|",
"************************",
"***********************"
],
“terrain”: {
".": “t_floor”,
"
": “t_grass”,
"~": “t_sidewalk”,
"-": “t_wall”,
"|": “t_wall”,
"+": “t_door_c”,
";": “t_door_locked”,
“i”: “t_door_locked_interior”,
":": “t_door_glass_c”,
“O”: “t_window”,
“9”: “t_window_domestic”,
“0”: “t_window_alarm”,
“W”: “t_chainfence_h”,
“w”: “t_chainfence_v”,
"^": “t_chaingate_c”,
"=": “t_wall_glass”,
"#": “t_floor”,
“h”: “t_floor”,
"[": “t_floor”,
“Z”: “t_floor”,
"$": “t_floor”,
“d”: “t_floor”,
"]": “t_floor”,
“s”: “t_floor”,
“t”: “t_floor”,
“B”: “t_floor”,
“y”: “t_floor”,
“F”: “t_floor”,
“D”: “t_floor”,
"?": “t_floor”,
“r”: “t_floor”,
"%": “t_console_broken”
},
“furniture”: {
"#": “f_counter”,
“h”: “f_chair”,
"[": “f_table”,
“Z”: “f_locker”,
"$": “f_safe_l”,
“d”: “f_desk”,
"]": “f_bookcase”,
“s”: “f_sink”,
“B”: “f_bed”,
“y”: “f_indoor_plant_y”,
“F”: “f_fridge”,
“D”: “f_trashcan”,
"?": “f_sofa”,
“r”: “f_rack”
},
“toilets”: {
“t”: “f_toilet”
},
“place_items”: [
{ “item”: “waitingroom”, “chance”: 60, “x”: 11, “y”: 3 },
{ “item”: “waitingroom”, “chance”: 60, “x”: 16, “y”: 20 },
{ “item”: “waitingroom”, “chance”: 60, “x”: [16,17], “y”: 6, “repeat”: [1,2] },
{ “item”: “doctorsoffice”, “chance”: 60, “x”: 19, “y”: [9,10], “repeat”: [1,2] },
{ “item”: “doctorsoffice”, “chance”: 60, “x”: 19, “y”: [13,14], “repeat”: [1,2] },
{ “item”: “cleaning”, “chance”: 60, “x”: 19, “y”: 17 },
{ “item”: “office”, “chance”: 50, “x”: [2,5,8], “y”: 5, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 50, “x”: [2,5,8], “y”: 8, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 50, “x”: [2,5,8], “y”: 11, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 20, “x”: [18,19,20,21], “y”: 3, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 20, “x”: 21, “y”: [4,5], “repeat”: [1,2] }

       ]
        "comment": "end of mapgen json definition ---v"
    },
    "comment": "end of mapgen entry ---v"
}

]

[/spoiler]

This from regional_map_settings.json:

“shops”: { “//”: “weighted list of oterrains for commercial zoning”,
“s_gas”: 5,
“s_pharm”: 3,
“s_grocery”: 15,
“s_hardware”: 5,
“s_sports”: 5,
“dojo”: 2,
“gym”: 1,
“gym_fitness”: 2,
“s_liquor”: 5,
“s_gun”: 5,
“s_clothes”: 5,
“s_library”: 2,
“s_bookstore”: 2,
“s_restaurant”: 4,
“sub_station”: 5,
“bank”: 3,
“s_pizza_parlor”: 4,
“bar”: 4,
“s_electronics”: 5,
“pawn”: 3,
“mil_surplus”: 2,
“s_garage”: 5,
“station_radio”: 4,
“office_doctor”: 2,
“s_restaurant_fast”: 4,
“s_restaurant_coffee”: 3,
“bowling_alley”: 2,
“church”: 2,
“office_cubical”: 2,
“furniture”: 2,
“abstorefront”: 2,
“police”: 1,
“fire_station”: 2,
“home_improvement”: 2,
“s_lot”: 4,
“s_arcade”: 2,
“s_jewelry”:2,
“s_antique”: 2,
“s_gardening”: 2,
“museum”: 1,
“s_music”: 2,
“s_laundromat”: 1,
“intcafe”: 3
}

This from overmap_terrain.json

       {
	"type" : "overmap_terrain",
	"id" : "intcafe",
	"name" : "cyber cafe",
	"rotate" : true,
	"sym" : [94, 62, 118, 60],
	"color" : "light_gray",
	"see_cost" : 5,
	"extras" : "build",
	"mondensity" : 2,
	"sidewalk" : true
}

I’m not seeing anything immediately that jumps out at me as wrong, except for:
[tt]
“toilets”: {
“t”: “f_toilet”
},
[/tt]

All you really need there is “t”: {}. The “toilets” field is just an easy way to place a set amount of water at the location specified. You still need to bind “t” to “f_toilet” in the furniture bindings.

This error happens when mapgen can’t find the json for the building itself.

That is, it places it on the overmap and rotates it correctly, but then fails at the generation itself. This suggests that the game can’t load the json file with the definition itself (the first file).

If the definition itself was wrong, you should get a different message first, at game load, before any mapgen takes place.

Looks like the game doesn’t see the file (and it reads all .json files in all subdirectories in data/json). Make sure it has the correct extension, is saved etc.

If that doesn’t work, try temporarily replacing it with some other definition (copy+paste it, just change the “om_terrain” to [“intcafe”]). If that still prints the error, I’m out of ideas. If it does generate the structure, it must mean that it silently discards your definition, which would be a bug (even if it has reasons to discard it, it should print a message).

And on a minor note: don’t use tabs. Use 4 spaces.

Moved .json into other directory, cleaned up the code. All works properly, thank very much, all of you!

UPD: How should I properly mark the coordinates for item groups and items spawning?

[quote=“Osobist, post:6, topic:10526”]Moved .json into other directory, cleaned up the code. All works properly, thank very much, all of you!

UPD: How should I properly mark the coordinates for item groups and items spawning?[/quote]

Format of a mapgen map is a 24x24 tile square, numbered 0-23, with X being horizontal and Y being vertical. If you need an example, guess I could snag a mapgen file to demonstrate with. XP

Here is my example. What is the “repeat” operator?

“place_items”: [
{ “item”: “waitingroom”, “chance”: 60, “x”: 11, “y”: 3 },
{ “item”: “waitingroom”, “chance”: 60, “x”: 16, “y”: 20 },
{ “item”: “waitingroom”, “chance”: 60, “x”: [16,17], “y”: 6, “repeat”: [1,2] },
{ “item”: “cleaning”, “chance”: 60, “x”: 19, “y”: 17 },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 5, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 8, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 11, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 50, “x”: 8, “y”: [5,8], “repeat”: [1,2] },
{ “item”: “office”, “chance”: 50, “x”: 8, “y”: 11 },
{ “item”: “office”, “chance”: 20, “x”: [18,19], “y”: 3, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 20, “x”: [20,21], “y”: 3, “repeat”: [1,2] },
{ “item”: “office”, “chance”: 20, “x”: 21, “y”: [4,5], “repeat”: [1,2] }
]

Fropm what I’ve seen, repeat isn’t mandatory, and seems to basically make it randomly re-roll that item placement a certain number of times, adding more chances or spawning stuff in that area.

At least I’m fairly certain that’s the way it works.

Something like “repeat”:[1, 2] means attempt that placement 1 to 2 times. These examples you cited are actually all incorrect, because the repeat field doesn’t really matter for item groups. Item groups do their own repetition when they roll for what items spawn. Repeat is usually used for things like single items, or to place random terrains. So if you tried to place a terrain with something like {“terrain”:“t_grass”, “x”:[1, 10], “y”:[1, 5], “repeat”:[3,9]} (note, not correct json) it would pick between 3 and 9 tiles in the range (1, 1) to (10, 5) and set them to t_grass.

Oh derp.

See, this is why I just copy-paste the item/itemgroup placement. Messier, but less finicky. ;A;

Oh, that’s interesting. And another problem: sometimes items not spawn in specified places (like in x: 5, y: 7), but spawn nearby. What should I do to avoid this?

Nearby like where? Keep in mind that those coordinates are indexed from 0 to 23, not 1 to 24.

On next tile. For example: I’ve added a trashcan in x8y8, but items spawn in x7x8.

You’re gonna have to show an example of the code that’s broken and possibly a screenshot of what it looks like in game as well.

Code:

{
“type”: “mapgen”,
“om_terrain”: [
“intcafe”
],
“method”: “json”,
“weight”: 500,
“object”: {
[pre] “rows”: [
",
"
”,
|-000000–|:|-000000-|”,
|y…r…#.ydddd|”,
0%…%…%…%h…hd0”,
0dh.dh.dh…#…d0”,
0…%h…0”,
0%…%…%…######.0”,
0dh.dh.dh…0”,
|…y|”,
|%…%…%…|±|±|”,
0dh.dh.dh…|.D|.D|”,
0…!|.s|.s|”,
0…|±|±|”,
|y…!!..y|.t|.t|”,
|------±------------|”,
“*|[[FD…]|PPPPPP%|.r|*", "*|h......]|.......|Z.r|*", "*0.......]|-+-----|Z.r|*", "*0d%d.....+.......i..r|*", "*|dh.....y|y????[y|..r|*", "*|---00------00-------|*", "************************", "************************" ], "terrain": { ".": "t_floor", "*": "t_grass", "~": "t_sidewalk", "-": "t_wall", "|": "t_wall", "+": "t_door_c", ";": "t_door_locked", "i": "t_door_locked_interior", ":": "t_door_glass_c", "O": "t_window", "9": "t_window_domestic", "0": "t_window_alarm", "W": "t_chainfence_h", "w": "t_chainfence_v", "^": "t_chaingate_c", "=": "t_wall_glass", "8": "t_floor", "h": "t_floor", "[": "t_floor", "Z": "t_floor", "”: “t_floor”,
“d”: “t_floor”,
“]”: “t_floor”,
“s”: “t_floor”,
“t”: “t_floor”,
“B”: “t_floor”,
“y”: “t_floor”,
“F”: “t_floor”,
“D”: “t_floor”,
“?”: “t_floor”,
“r”: “t_floor”,
“!”: “t_floor”,
“#”: “t_floor”,
“%”: “t_console_broken”,
“P”: “t_sai_box”
},
“furniture”: {
“#”: “f_counter”,
“h”: “f_chair”,
“[”: “f_table”,
“Z”: “f_locker”,
“$”: “f_safe_l”,
“d”: “f_desk”,
“]”: “f_bookcase”,
“s”: “f_sink”,
“B”: “f_bed”,
“y”: “f_indoor_plant”,
“F”: “f_fridge”,
“D”: “f_trashcan”,
“?”: “f_sofa”,
“r”: “f_rack”,
“t”: “f_toilet”,
“!”: “f_vending_c”
},
“toilets”: {
“t”: {}
},
“place_vendingmachines”: [
{ “x”: 15, “y”: 12 },
{ “x”: 11, “y”: 14 },
{ “x”: 12, “y”: 14 }
],
“add”: [
{ “item”: “microwave”, “x”: 3, “y”: 15, “chance”: 90 },
{ “item”: “pda”, “x”: 15, “y”: 3, “chance”: 60 }
],
“place_items”: [
{ “item”: “waitingroom”, “chance”: 60, “x”: 11, “y”: 3 },
{ “item”: “waitingroom”, “chance”: 60, “x”: 16, “y”: 20 },
{ “item”: “waitingroom”, “chance”: 60, “x”: [16,17], “y”: 7 },
{ “item”: “waitingroom”, “chance”: 60, “x”: [18,19], “y”: 7 },
{ “item”: “trash_intcafe”, “chance”: 50, “x”: [17,20], “y”: 12 },
{ “item”: “trash_intcafe”, “chance”: 30, “x”: 5, “y”: 17 },
{ “item”: “cleaning”, “chance”: 60, “x”: 19, “y”: 17 },
{ “item”: “fast_food”, “chance”: 30, “x”: 4, “y”: 15 },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 5 },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 8 },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 11 },
{ “item”: “office”, “chance”: 50, “x”: 8, “y”: [5,8] },
{ “item”: “office”, “chance”: 50, “x”: 8, “y”: 11 },
{ “item”: “office”, “chance”: 20, “x”: [18,19], “y”: 3 },
{ “item”: “office”, “chance”: 20, “x”: [20,21], “y”: 3 },
{ “item”: “office”, “chance”: 20, “x”: 21, “y”: [4,5] },
{ “item”: “office”, “chance”: 20, “x”: 2, “y”: [19,20] },
{ “item”: “office”, “chance”: 20, “x”: 2, “y”: [19,20] },
{ “item”: “electronics_intcafe”, “chance”: 40, “x”: 21, “y”: [15,16] },
{ “item”: “electronics_intcafe”, “chance”: 40, “x”: 21, “y”: [17,18] },
{ “item”: “electronics_intcafe”, “chance”: 40, “x”: 21, “y”: 19 },
{ “item”: “books_intcafe”, “chance”: 40, “x”: 9, “y”: [15,16] },
{ “item”: “books_intcafe”, “chance”: 40, “x”: 9, “y”: 17 },
{ “item”: “intcafe_safe”, “chance”: 70, “x”: [ 19,19 ], “y”: [ 16,16 ]}

       ],
        "comment": "end of mapgen json definition ---v"
    },
    "comment": "end of mapgen entry ---v"
}

]
[/pre]

Screenshot:

Check the pile of glasses on the floor. They should lay on table.

[tt]
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 5 },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 8 },
{ “item”: “office”, “chance”: 50, “x”: [2,5], “y”: 11 },
{ “item”: “office”, “chance”: 50, “x”: 8, “y”: [5,8] },
{ “item”: “office”, “chance”: 50, “x”: 8, “y”: 11 },
[/tt]

You have desks at (2,5), (5,5), (8,5), (2,8), (5,8), (8,8), (2,11), (5,11), and (8,11). You need to specify each of these individually, as in { “x”:5, “y”:2 }, not using the array notation, as in { “x”:[5,8], “y”:2 }. The array notation tries to place that group between the values 5 and 8, so instead of a single point group at the location, you end up with a line going from (5, 2) to (8, 2).

Edit: mixed up x and y coordinates.

Understood, thanks for the help! I’ll fix it tomorrow.

Hello. Don’t want to produce multiple threads, so I’ll ask here: is there any mean to add new iuse function only in mode, without touching the main game data?

hmmm this seams like the wrong thread for that kind of question…