# How to program a new item into the game?

**URL:** https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156
**Category:** The Drawing Board
**Created:** [December 1, 2014, 5:27pm UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156 "2014-12-01T17:27:19Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![DrNightmares](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/drnightmares/32/12344_2.png) [@DrNightmares](https://discourse.cataclysmdda.org/u/DrNightmares)
#### Post date: [December 1, 2014, 5:27pm UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156/1 "2014-12-01T17:27:19Z")

</div>

I’m trying to make a Steam machine that’ll gentrate power for your car’s battery by burning wood and using up water.

Right now, I’m stuck on one part…Finding the ID list. I need to go to the Minireactor’s ID and a engine’s ID to chop them up and build a proper steampunk machine ID that’ll make power from logs and draw from your supply of clean water like gas.

The power it makes is 1/3 of the power the truck alternator makes due to the energy density of wood compared to gas. I still need to polish that bit a little, do some more math based on the weight of each logs in the game. How much do one unit of gas weights?

I might also need to take a look at the location list to be sure that I don’t have to add logs to that list or something. Make it so one unit of log burns for x time, etc.

(Old, see edit at end of this post)  
  “type” : “vehicle\_part”,  
“id” : “minireactor”,  
“name” : “Steam Furnace Rig”,  
“symbol” : “F”,  
“color” : “light\_green”,  
“broken\_symbol” : “#”,  
“broken\_color” : “red”,  
“damage\_modifier” : 80,  
“durability” : 580,  
“size” : 10000,  
“epower” : 746,  
“fuel\_type” : “log”,  
“item” : “minireactor”,  
“difficulty” : 5,  
“location” : “fuel\_source”,  
“flags” : [“FUEL\_TANK”],  
“breaks\_into” : [  
{“item”: “steel\_lump”, “min”: 6, “max”: 11},  
{“item”: “steel\_chunk”, “min”: 6, “max”: 11},  
{“item”: “scrap”, “min”: 6, “max”: 11}

Once that wall’s overcame, I’ll edit this thing a bit more, spit and polish then throw it back here for feedbacks.

Edit: My process so far.

[spoiler]  
In the main data folder, Vehicle\_Parts.Json, I added this.

{  
“type” : “vehicle\_part”,  
“id” : “steampunkrig”,  
“name” : “Steam Furnace Rig”,  
“symbol” : “F”,  
“color” : “light\_green”,  
“broken\_symbol” : “#”,  
“broken\_color” : “red”,  
“damage\_modifier” : 80,  
“durability” : 580,  
“size” : 10000,  
“epower” : 746,  
“fuel\_type” : “log”,  
“item” : “steampunkrig”,  
“difficulty” : 5,  
“location” : “fuel\_source”,  
“flags” : [“FUEL\_TANK”],  
“breaks\_into” : [  
{“item”: “steel\_lump”, “min”: 12, “max”: 30},  
{“item”: “steel\_chunk”, “min”: 12, “max”: 30},  
{“item”: “scrap”, “min”: 12, “max”: 30}  
},

And in the data/item/Vehicle\_parts.json, I added this.

{  
“type”:“GENERIC”,  
“id” : “steampunkrig”,  
“name” : “Steam Furnace Rig”,  
“description” : “A Steam Furnace that boils water into steam to turn fans to generate power. Uses clean water and logs.”,  
“weight” : 58215,  
“to\_hit” : -4,  
“color” : “light\_green”,  
“symbol” : “f”,  
“material” : [“steel”],  
“volume” : 6,  
“bashing” : 7,  
“cutting” : 0,  
“category” : “veh\_parts”,  
“price” : 40000  
},

And in Data/Recipes/Recipe\_electronics, I added this.

{  
“type” : “recipe”,  
  “result”: “steampunkrig”, (This is right? Put the ID of the item here?)  
“category”: “CC\_ELECTRONIC”,  
“subcategory”: “CSC\_ELECTRONIC\_PARTS”,  
“skill\_used”: “mechanics”,  
“skills\_required”: [“electronics”,7],  
“difficulty”: 4,  
  “time”: 60000, Need to edit this to ten hours. What’s the units here?  
“reversible”: false,  
“decomp\_learn”: 4,  
“autolearn”: false,  
“book\_learn”: [[“textbook\_mechanics”, 6] , [“textbook\_electronics”, 8] , [“textbook\_fabrication”, 8] , [“welding\_book”, 5]],  
“qualities”:[  
{“id”:“HAMMER”,“level”:2,“amount”:1},  
{“id”:“SAW\_M”,“level”:1,“amount”:1},  
{“id”:“WRENCH”,“level”:1,“amount”:1}  
], “tools”: [  
[  
[“goggles\_welding”, -1]  
],  
[  
[“welder”, 100],  
[“welder\_crude”, 150],  
[“toolset”, 150]  
]  
],  
“components”: [  
[  
[“frame”, 1]  
],  
[  
[“soldering\_iron”, 1]  
],  
[  
[“steel\_lump”, 12],  
[“steel\_chunk”, 50],  
[“scrap”, 150]  
[“copper\_wire”, 300]  
],  
[  
[“cable”, 5]  
]  
]  
},

I still can’t find the .json that controls how much fuel engines draws on, etc. I need help! Seems that I’m more than halfway finished here.[/spoiler]

---

<div class="post-metadata">

### Author: ![FunsizeNinja123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/funsizeninja123/32/118_2.png) [@FunsizeNinja123](https://discourse.cataclysmdda.org/u/FunsizeNinja123)
#### Post date: [December 1, 2014, 9:55pm UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156/2 "2014-12-01T21:55:21Z")

</div>

Fairly sure that you can just type “habfhubfkhuabkfb” into the ID list and it’ll work because IDs define the item itself, nothing else.

---

<div class="post-metadata">

### Author: ![i2amroy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/i2amroy/32/909_2.png) [@i2amroy](https://discourse.cataclysmdda.org/u/i2amroy)
#### Post date: [December 1, 2014, 10:03pm UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156/3 "2014-12-01T22:03:17Z")

</div>

“id” can be anything you want (preferably all lowercase and with underscores instead of spaces).

As I understand it the “item” field is the “id” value of the item that you “install” to make the defined vehicle part (which has it’s own definition in the items folder).

---

<div class="post-metadata">

### Author: ![FunsizeNinja123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/funsizeninja123/32/118_2.png) [@FunsizeNinja123](https://discourse.cataclysmdda.org/u/FunsizeNinja123)
#### Post date: [December 1, 2014, 10:07pm UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156/4 "2014-12-01T22:07:57Z")

</div>

> [@i2amroy](#):
>
> “id” can be anything you want (preferably all lowercase and with underscores instead of spaces).

Oh yeah, don’t forget that. I learned that the hard way…

---

<div class="post-metadata">

### Author: ![DrNightmares](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/drnightmares/32/12344_2.png) [@DrNightmares](https://discourse.cataclysmdda.org/u/DrNightmares)
#### Post date: [December 2, 2014, 3:03am UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156/5 "2014-12-02T03:03:05Z")

</div>

[quote=“i2amroy, post:3, topic:8156”]“id” can be anything you want (preferably all lowercase and with underscores instead of spaces).

As I understand it the “item” field is the “id” value of the item that you “install” to make the defined vehicle part (which has it’s own definition in the items folder).[/quote]

Ooh, here we go. Thanks!

I’ll be wanting to ask how to turn this into a add-on, a mod for the game after I make the new “item”.

---

<div class="post-metadata">

### Author: ![DrNightmares](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/drnightmares/32/12344_2.png) [@DrNightmares](https://discourse.cataclysmdda.org/u/DrNightmares)
#### Post date: [December 2, 2014, 4:04am UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156/6 "2014-12-02T04:04:41Z")

</div>

Okay.

In the main data folder, Vehicle\_Parts.Json, I added this.

{  
“type” : “vehicle\_part”,  
“id” : “steampunkrig”,  
“name” : “Steam Furnace Rig”,  
“symbol” : “F”,  
“color” : “light\_green”,  
“broken\_symbol” : “#”,  
“broken\_color” : “red”,  
“damage\_modifier” : 80,  
“durability” : 580,  
“size” : 10000,  
“epower” : 746,  
“fuel\_type” : “log”,  
“item” : “steampunkrig”,  
“difficulty” : 5,  
“location” : “fuel\_source”,  
“flags” : [“FUEL\_TANK”],  
“breaks\_into” : [  
{“item”: “steel\_lump”, “min”: 12, “max”: 30},  
{“item”: “steel\_chunk”, “min”: 12, “max”: 30},  
{“item”: “scrap”, “min”: 12, “max”: 30}  
},

And in the data/item/Vehicle\_parts.json, I added this.

{  
“type”:“GENERIC”,  
“id” : “steampunkrig”,  
“name” : “Steam Furnace Rig”,  
“description” : “A Steam Furnace that boils water into steam to turn fans to generate power. Uses clean water and logs.”,  
“weight” : 58215,  
“to\_hit” : -4,  
“color” : “light\_green”,  
“symbol” : “f”,  
“material” : [“steel”],  
“volume” : 6,  
“bashing” : 7,  
“cutting” : 0,  
“category” : “veh\_parts”,  
“price” : 40000  
},

And in Data/Recipes/Recipe\_electronics, I added this.

{  
“type” : “recipe”,  
“result”: “steampunkrig”, (This is right? Put the ID of the item here?)  
“category”: “CC\_ELECTRONIC”,  
“subcategory”: “CSC\_ELECTRONIC\_PARTS”,  
“skill\_used”: “mechanics”,  
“skills\_required”: [“electronics”,7],  
“difficulty”: 4,  
  “time”: 60000, Need to edit this to ten hours. What’s the units here?  
“reversible”: false,  
“decomp\_learn”: 4,  
“autolearn”: false,  
“book\_learn”: [[“textbook\_mechanics”, 6] , [“textbook\_electronics”, 8] , [“textbook\_fabrication”, 8] , [“welding\_book”, 5]],  
“qualities”:[  
{“id”:“HAMMER”,“level”:2,“amount”:1},  
{“id”:“SAW\_M”,“level”:1,“amount”:1},  
{“id”:“WRENCH”,“level”:1,“amount”:1}  
], “tools”: [  
[  
[“goggles\_welding”, -1]  
],  
[  
[“welder”, 100],  
[“welder\_crude”, 150],  
[“toolset”, 150]  
]  
],  
“components”: [  
[  
[“frame”, 1]  
],  
[  
[“soldering\_iron”, 1]  
],  
[  
[“steel\_lump”, 12],  
[“steel\_chunk”, 50],  
[“scrap”, 150]  
[“copper\_wire”, 300]  
],  
[  
[“cable”, 5]  
]  
]  
},

I still can’t find the .json that controls how much fuel engines draws on, etc. I need help! Seems that I’m more than halfway finished here.

---

<div class="post-metadata">

### Author: ![Coolthulhu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/coolthulhu/32/2446_2.png) [@Coolthulhu](https://discourse.cataclysmdda.org/u/Coolthulhu)
#### Post date: [December 2, 2014, 6:53am UTC](https://discourse.cataclysmdda.org/t/how-to-program-a-new-item-into-the-game/8156/7 "2014-12-02T06:53:59Z")

</div>

It’s a bit more complicated.

You need to mess with src/vehicle.cpp.

Fuel consumption multipliers are hardcoded at the moment, you can’t edit them from json level.

But this is a bit more complex than that, because your engine should also consume water. It might be as easy as adding appropriate "if"s in consume\_fuel and fuel\_left functions (if fuel\_type == wood) or it may require a bit more.
