JSON, misadventures in Modding and tears. [please help...]

I am at the point of tears. I have done everything I can think of, I’ve combed though every line of code ten times but, whatever the problem is, I can’t find it.

Background: I like this game and have been playing it for some years. I’ve watched it from the humble beginnings all the way to now. I also like Warhammer 40,000. So, naturally, I decided to put the two together.

Now, I’m not saying that I’ll be making a mod that encompasses the 40K universe. Right now I just want to make a proof of concept and to see if I like doing this (I probably will because code is a puzzle and i really like puzzles.).

Problem: The console loads fine and every mod loads just great. The compile is fine. When I select my mod and load a world it goes though the DDA files and then stalls when attempting to load the mod. The debugger will not display, however, compounding the problems and exponentially expanding my frustration.

Anyway, I put my code in spoilers so as not to nom the the page. If there’s something I’ve missed, let me know. If there’s a step involved that I’m not getting, refer to the previous line.

gun.json

[
{
“id”: “Godwin_Bolter”,
“type”: “GUN”,
“name”: “Godwin Pattern Bolter”,
“name_plural” : “Godwin Pattern Bolters”,
“description”: “A massive handheld rifle that fires rounds the size of beer cans.”,
“weight”: 20,
“volume”: 4,
“price”: 6000000,
“to_hit”: -2,
“bashing”: 14,
“ranged_damage” : 3,
“material”: “steel”,
“symbol” : “(”
“color”: “light_gray”,
“ammo”: “bolt”,
“dispersion”: 40,
“durability”: 10,
“loudness” : 30,
“reload” : 180,
“barrel_length” : 1,
“magazines”:[ [ “bolt”, [ “BolterSickleMag_30”, [ BolterSickleMag_25, [ BolterSickleMag_20, ] ] ] ]
}
]

ammo.json

[
{
“id”: “bolt”,
“type”: “AMMO”,
“name”: “.75 Bolt”,
“name_plural”: “.75 Bolts”,
“description”: “Case of standard Boltgun rounds. A Mass-reactive charge inside the round explodes when hitting a solid mass.”,
“weight”: 20,
“volume”: 3,
“price”: 250000,
“material”: [ “brass”, “powder”, “steel” ],
“symbol”: “=”,
“color”: “green”,
“bashing” : 1,
“cutting” : 0,
“to_hit” : 0,
“ammo_type”: “bolt”,
“damage” : 60,
“pierce” : 10,
“range” : 24,
“dispersion” : 30,
“recoil” : 750,
“count” : 50,
“stack_size”: 35,
“effects”: [ “COOKOFF”, “EXPLOSIVE”, “MUZZLE_SMOKE”, “SMOKE”, “FRAG”, “FLASHBANG”]

}
]

magazine.json

[
{
“id”: “BoltPistolMag_9”,
“type”: “MAGAZINE”,
“name”: “Bolt Pistol Magazine”,
“description”: “A 9-round magazine for a Bolt Pistol.”,
“Weight”: 100,
“Volume”: 2,
“Price”: 10000,
“material” : “steel”,
“symbol” : “#”
“color” : “light_gray”,
“ammo_type”: “bolt”,
“capacity”: 9
"reliability" : 10
"reload_time" : 120
},
{
“id”: “BolterSickleMag_20”,
“type”: “MAGAZINE”,
“name”: “20-Round Bolter MAGAZINE”,
“description”: “A 20 round sickle magazine for the holy Bolter.”,
“Volume”: 2,
“Price”: 10000,
“material” : “steel”,
“symbol” : “#”
“color” : “light_gray”,
“capacity” : 20,
“weight”: 160,
“ammo_type”: “bolt”
“reliability” : 10
"reload_time" : 200
},
{
“id”: “BolterSickleMag_25”,
“type”: “MAGAZINE”,
“name”: “25-Round Bolter MAGAZINE”,
“description”: “A 25 round sickle magazine for the holy Bolter.”,
“Volume”: 2,
“Price”: 10000,
“material” : “steel”,
“symbol” : “#”
“color” : “light_gray”,
“capacity” : 25,
“weight”: 180,
“ammo_type”: “bolt”
“reliability” : 10
"reload_time" : 250
},
{
“id”: “BolterSickleMag_30”,
“type”: “MAGAZINE”,
“name”: “30-Round Bolter MAGAZINE”,
“description”: “A 30 round sickle magazine for the holy Bolter.”,
“weight”: 200,
“Volume”: 2,
“Price”: 10000,
“material” : “steel”,
“symbol” : “#”
“color” : “light_gray”,
“capacity” : 30,
“ammo_type”: “bolt”
“reliability” : 10
"reload_time" : 280

}

]

ammo_types.json

[
{
“id”: “bolt”,
“name”: “.75mm Bolt”,
“default”: “bolt”,
“type”: “ammunition_type”
}
]

What is the problem here?
I mean, some error that prevents loading, items not working or what?

[quote=“Coolthulhu, post:2, topic:13554”]What is the problem here?
I mean, some error that prevents loading, items not working or what?[/quote]
(Coolthulu replied to my post! Alright, don’t freak out.)
“Hi.” (Crap…)

Sorry. Fixed it in the main description.

Anyway, the main problem is that I don’t know. The debugger isn’t displaying anything at all.

There’s clearly an error, however because I push “I” when it’s stalled at my mod when loading the world and boots me to the main menu.

Have you turned off debug mode?

It’s a fresh compile. Should I turn it on?

That was a stupid question. I’ll turn it on and report back on what it says.

Right well, no debug messages show in console or in Code::Blocks. All it does is stall and refuse to load when it gets to “Please wait while the world data loads… Loading content (40K)”

Edit: Just ran it though the CB debugger again and it threw this error.

In __cxa_throw () ()
#1 0x007adc38 in JsonIn::error (this=this@entry=0x13f6886c, message=…, offset=1) at C:\Users[b]REDACTED[/b]\Downloads\CataDDAGit\src\json.cpp:1513
C:\Users[b]REDACTED[/b]\Downloads\CataDDAGit\src\json.cpp:1513:33711:beg:0x7adc38
At C:\Users[b]REDACTED[/b]\Downloads\CataDDAGit\src\json.cpp:1513

You have invalid content in gun.json:

“magazines”:[ [ “bolt”, [ “BolterSickleMag_30”, [ BolterSickleMag_25, [ BolterSickleMag_20, ] ] ] ]

Should be probably like this:

“magazines”:[ [ “bolt”, [ “BolterSickleMag_30”, “BolterSickleMag_25”, “BolterSickleMag_20” ] ] ]


Also multiple commas are missing which makes json syntax bad.

[quote=“Zhilkin, post:7, topic:13554”]You have invalid content in gun.json:

“magazines”:[ [ “bolt”, [ “BolterSickleMag_30”, [ BolterSickleMag_25, [ BolterSickleMag_20, ] ] ] ]

Should be probably like this:

“magazines”:[ [ “bolt”, [ “BolterSickleMag_30”, “BolterSickleMag_25”, “BolterSickleMag_20” ] ] ][/quote]

This has taught me a valuable lesson; Always read the code one more time.

I’m compiling now and then we’ll see if that fixes it. Honestly, thank you so much. I never expected this much help or support! I’ll be back when CB is done munching and let you know.

You don’t need to recompile, just put updated json to game folder.

It threw this error in the debugger.

http://imgur.com/a/AcBN2

No, you don’t need to recompile - JSON is not compiled. It is read and interpreted by the game. Restarting/reloading the game is usually enough to apply changes to JSON. Here are updated files packed into mod: https://www.dropbox.com/s/0cvisdci7m3wm7c/WH40KGuns.zip?dl=0. Just unzip it into mod folder and add mod to world settings.

The gun works, but it only can be spawned via debug menu, so you will need to add or update some item groups to have gun, magazines and ammo spawn somewhere.

The explosion is rather big, though it could be okay for WH40K.

[quote=“Zhilkin, post:11, topic:13554”]No, you don’t need to recompile - JSON is not compiled. It is read and interpreted by the game. Restarting/reloading the game is usually enough to apply changes to JSON. Here are updated files packed into mod: https://www.dropbox.com/s/0cvisdci7m3wm7c/WH40KGuns.zip?dl=0. Just unzip it into mod folder and add mod to world settings.

The gun works, but it only can be spawned via debug menu, so you will need to add or update some item groups to have gun, magazines and ammo spawn somewhere.

The explosion is rather big, though it could be okay for WH40K.[/quote]

How the hell did you get that to work? I must learn from the strange codeamancy that you practice.

Seriously, what was I missing?

Json syntax was incorrect: missing commas, missing parenthesis, missing quotation marks.

You can compare files in some text compare tool to see what was changed.

If you’re only changing jsons (and not sources), test it on a downloaded tiles build.
The windows curses build has some known problems, such as not displaying the errors and not going fast (less than half the FPS).

[quote=“Zhilkin, post:13, topic:13554”]Json syntax was incorrect: missing commas, missing parenthesis, missing quotation marks.

You can compare files in some text compare tool to see what was changed.[/quote]

Thank you, thank you, thank you! you’ve made me so much more confident in doing JSON now! [quote=“Coolthulhu, post:14, topic:13554”][quote=“Wulfle, post:3, topic:13554”]Anyway, the main problem is that I don’t know. The debugger isn’t displaying anything at all.[/quote]

If you’re only changing jsons (and not sources), test it on a downloaded tiles build.
The windows curses build has some known problems, such as not displaying the errors and not going fast (less than half the FPS).[/quote]

Thank you both so much! This has made me so much more eager to do this now! I can’t wait to start on other weapons, rounds and factions. I’m very exited now. The support and help that I’ve received here has only made me love this game even more.

Don’t be so excited - I’ve heard factions are broken. :slight_smile:

Yeah but I think that nids would add to the experance. Not Chaos Marines or Eldar or anything like that yet but a few bolters, a chainsword, some diffrent types of rounds and Power Armor. If I can get that, I’ll work on balance. After that, I’ll add more stuff. Maybe Sorotas or Imperial Guard things. Then the cycle of add-ballance will begin again.

Also, yeah, the explosion is WAY to big. I removed the explosion flag and am just using the frag now.

You can create custom explosions.

After coming from programming class, seeing how eager you are makes me inspired. Head on, pal!

I dunno haow…! cries

I’m rather self-taught. I started learning on RUBY and did a bit of Python and Java as well as some rudimentary C and C# but nothing really noteworthy. I’m glad that I inspired you!