It was pretty easy; I simply copied the relevant bits of JSON in /data/json/vehicleparts/vehicle_parts.json and edited as needed:
{
"type": "vehicle_part",
"id": "cargo_space",
"name": { "str": "cargo space" },
"symbol": "=",
"looks_like": "box",
"color": "light_gray",
"broken_symbol": "#",
"broken_color": "dark_gray",
"durability": 250,
"size": 1000,
"item": "cargo_rack",
"location": "center",
"requirements": {
"install": { "skills": [ [ "mechanics", 1 ] ], "time": "60 m", "using": [ [ "welding_standard", 5 ] ] },
"removal": { "skills": [ [ "mechanics", 2 ] ], "time": "30 m", "using": [ [ "vehicle_weld_removal", 1 ] ] },
"repair": { "skills": [ [ "mechanics", 2 ] ], "time": "60 m", "using": [ [ "welding_standard", 5 ] ] }
},
"flags": [ "BOARDABLE", "CARGO", "COVERED" ],
"breaks_into": [
{ "item": "steel_lump", "count": [ 6, 8 ] },
{ "item": "steel_chunk", "count": [ 6, 8 ] },
{ "item": "scrap", "count": [ 6, 8 ] }
],
"damage_reduction": { "all": 28 }
},
Copy/paste the entire block above and change these two lines:
"id": "cargo_space_weapon",
"name": { "str": "gun storage" },
Save the JSON file and hey presto, you now have a new part you can install in vehicles. Just be careful to keep commas and curly brackets in the right places - I’d recommend making a backup copy of vehicle_parts.json before making changes. To get a custom sprite you’ll need to open the spritesheet (/gfx/RetroDays+Tileset/tiles.png in my case) in a photo editor (I use GIMP) and add a new sprite to the end (10 x 10 pixels). Then open tile_config.json in the same folder and add an entry for your new item, e.g.
{
"id": "vp_cargo_space_weapon",
"fg": 3097,
"rotates": false,
"multitile": true,
"additional_tiles": [ { "id": "broken", "fg": 155 } ]
},
“fg” is the number of the sprite you want the item to use, starting from top left of spritesheet (yeah, there really are more than three thousand sprites in there). Note that you need to prefix the item id with “vp_” (for vehicle part) in order for the game to find it (this had me stumped at first). Happy modding!