[In-progress] Base mod! generators

I’m thinking about making a vehicle_part generator if I can like an engine but it had a container for fuel, some base building is done through vehicle building

I saw an old post an looked through the JSON while I was writing down some prep work for a mod.

I currently have everything working, but I need advice before I post,

  1. how much idle power should they draw and should diesel use less?

  2. should i add 2 variants of bio_diesel generator and others if it makes sense

  3. should this be a pr?

for what i understand right now there is no base menu as such so i made it for a vehicle.
if you know what your doing this opens up abit-more in the early-game possible mid-game.

yet to test if they will work as intended. but I see no reason why not right now. i will test when I get time soon


  1. I’d try to search for info about real life diesel generators, preferably the kind used for backup in places where there are frequent outages (or critical facilities like hospitals, but I’d expect those to be too large), rather than the ones used at building sites.

  2. I’d probably either use diesel/bio diesel (at a lower efficiency) as fuel, like diesel engines. It might be possible to have a more primitive lower tech version and a higher tech one (with the less advanced one using more fuel). I’d also consider whether the primitive one should to be a fixed rate burn one, as that’s definitely primitive.

  3. Definitely something for the core team to answer.


i have this working but not as intended, it doesn’t have a pocket so there is no container on this. you its not a standalone working generator plug and play you need to install the part lol

From some quick searching there doesn’t seem to be anykind of meaningfull difference between diesel and biodiesel so any generator that runs on either should be able to run on the other just fine.

ive added the flag and item restriction and it doesnt like biodiesel for me ill leave it in incase i did something wrong no more time to test

I’ve mentioned this on the development discord server, but I’ll expand my comments more fully here:

CDDA has a robust infrastructure for vehicles. That infrastructure doesn’t currently support installing engines solely to run alternators to produce electrical power, but it wouldn’t be too hard to add and I’d be willing to offer advice to a programmer new to CDDA who wanted to try to implement it.

CDDA doesn’t currently have a way to implement “appliances”, by which I mean things that are technically vehicles but which the avatar interacts with as though they were items. This is something that people want to see added but it’s a large task and I’m not particularly interested in it. If someone wants to implement generators as tools, probably the best way to implement that is generators as vehicle parts (see above) and then add an “appliance” interface. This is pretty complicated but again, I’m willing to offer technical support and answer questions from a programmer who wants to take a swing at it.

A generator as an entirely stand-alone tool/item is pretty unlikely at this time. Doing that would require significant C++ coding support without moving us any closer to the general solution of “appliances” and in a lot of ways moving us farther away from them. I’m not going to forbid it, but I am not offering to help and I am warning that it’s going to get a tough struggle to get the code support for a stand-alone generator tool added to the code base. The only possible exception I could see would be a stand-alone battery recharger powered by a combustion engine; I’m not wild about the concept but it might be possible to make that work. I’d rather see vehicle part generators and an appliance infrastructure.

Questions, comments, and counter-arguments are welcome, but what I’d most like to see is someone volunteering to take on the C++ coding aspects of these tasks.

(BTW, for those of you who aren’t aware, I’m the vehicles maintainer for CDDA and I’ve consulted with the rest of the senior CDDA dev team so this is pretty much the official response. You’re welcome to try to change my mind but you’re going to need some pretty good arguments as to why a different proposed solution would be better.)


Long time fan of your work, but a question about power grid/wiring/etc future implementation possibilities.

If you look in real life, wiring is part of constructed walls in pretty much every building except for things meant to be off grid like some cabins or storage sheds.

Would it be possible to have the walls themselves act as wires in code?

Of course, this assumes outlets which would have to be implemented. Also, houses have breaker boxes.

But, while not every survivor would be able to do it, it should be possible with high electronics and commercial construction skills and equipment using existing wiring to power back on a house eventually. (Of course, reestablishing power to a town would be out of scope for this - but I am sure some of the cool kids would try)

Would just changing most walls in game to “walls with wiring inside” help with this implementation?

The over all end game of this would be promising. We have TVs that could be powered on to play movies for morale. Air conditioners and heaters. Actually using an oven instead of burning planks in there. Of course, all making noise and attracting friends.

Thanks and appreciate your hard work.

1 Like

The “appliance” concept is intended to address the idea of powered walls. For various reasons dealing with the way we load maps into memory, powered walls are going to need to be vehicles under the hood, just skinned through a different ‘examine’ layer.

Unfortunately, it’s not something I hugely care about, so while I’m willing to help someone else do it, I’m not motivated to do the work myself.

And you’re welcome! Thank you for the appreciation and kind words.


Understood. This game is very complex with what it lets you do already. Plus, time.

But you got to admit, that would be cool.

If I am getting the image you have for this right, it would be like a layer. Kind of like the layers in the old Sim City titles where you look into plumbing, grid, etc but using the existing vehicle interface. "e"xamined from the character’s viewpoint, though.

Good luck.

Makes me wish I was a coder sometimes. Then I’d get into rabbit holes and my family would never see me :slight_smile:

1 Like

I’ve noticed terrain witch should have more code well the counter part code, hmm what’s the issue with it being difficult, wouldn’t appliance be like menus with the menu activating, if no ones up for implementing base building electricity I’ll consider it but rn I’ve got to much mod work, family life and building todo. atm I have relaxed deadlines now for mods witch I know ill beat, GMC first.

But this wouldn’t do anything without other code, this should happen to keep the features ball rolling. The generators would have appliance maybe turn on but without normal electricity. well, there should be some sort of electricity or why do fridges work Constant? blocker? or code that makes it magically work?

I’d like to at least be able to have menus or at least something telling you have disconnected/unplugged the appliance/plug

Why would you rather base building in-vehicle JSON? I don’t see a generator as a vehicle, but I know there are large two-wheeled and four-wheeled towed generators. I think we may be getting mixed up on this? I mean a standard small 5 - 25 generator I think 25 is a lot, i think if you end up using Vehicle building menu it will need extended and i think it would be simpler to just add a new variation because later down the line you will want a separate menu all together things might get confusing if it’s in the same menu because of the amount of different things you can build

solution 1
Make the game lose electricity after x amount of days

Solution 2
Get rid of electricity being a thing entirely (not code-wise) to make base building be of a thing that players want to do

Or there no point in using generators/other base power because you can literally take a fridge out a building that’s powered and move it where ever and it will work. this shouldn’t be a thing. but to apply base building menu this to every building and house might take some work witch if you use vehicle build menu for this it will be weird as well.

actually, i think the base building should work independently of any menus like how construction works but would require menus of its own when using as I have mentioned before.

I have no idea how you got “it still needs an alternator” from my previous postings and I’m not even sure what noun “it” is replacing in that sentence.

Good luck with whatever out-of-tree, mod-only thing you’re trying to attempt.

1 Like

I’ll edit and post tomorrow

Expanding on previous answer a bit more:

The solution I’d like see looks like this:

  • There would be JSON for multiple vehicle parts that are generator versions of the current engines, so “v2 gasoline generator” or “large gas turbine generator”. They would probably lighter than the current engines (no implicit transmission) but occupy the same location in a vehicle and consume the same amount of fuel when operating.
  • There would be a new bunch of code for dealing with these, but the short version is that generators act like engines EXCEPT you can install multiple generators without instruction, generators don’t contribute to the motive power of the vehicle, and generators don’t count as extra engines for multiple engine motive power penalties.
  • There would be a bunch of new code for “appliances”. Internally to the code, appliances would be vehicles (though usually without wheels) but you’d interact with them as though they were items, mostly.
  • Your stand-alone generator (SAG) would be represented in JSON as a wheelless vehicle (or appliance) with a special frame, a small combustion engine, a car or motorcycle alternator, and a 2L fuel tank. You’d interact with the SAG as an item via some special commands, so there would be an action to refill the tank, an action to connect the generator to other appliances, etc. Notably, you’d use the craft menu (and not the vehicle interaction menu) to craft a new SAG or build a recharging station from a SAG and a recharging station, and you wouldn’t be able to remove parts from the SAG like you can with a vehicle, but only disassemble it like any other item. You could store a SAG in large container like a duffel bag (well, maybe, depending on the size). But the code would treat it as a vehicle, so the existing code to handle fuel consumption and power production would work just fine.

Now, this version of appliances is, as I’ve said a lot of work and I’m not going to do it. But I’m also not going to do the work to add a generator item that consumes fuel and generates electrical power when it’s on the active item list. The difference is I’m going to help someone else implement the appliance idea, and I’m going to work against anyone trying to implement the active item version.

Now I am reasonably sure that you don’t understand all of what I just said, which isn’t a problem except that it makes it difficult for you to make convincing arguments for your version of the solution to the problem. I can try to help you understand this stuff, if you’d like, but it means understanding elements of how CDDA is written in C++ and I don’t know if you want to do that.

Powered walls wouldn’t be a “layer” and you wouldn’t look at them through the existing vehicle interface. That’s exactly backwards of what we want.

Powered walls would be a vehicle (without wheels, obviously) internally to the code, and would be loaded as a vehicle and processed as a vehicle. However, when you examined them, instead of getting the vehicle interaction menu, you’d get the same sort of data you’d get from examining a piece of terrain or furniture.

There’s some complicated details on the implementation, but that’s the big take-away. Powered walls will be vehicles, but you won’t interact with them as they though they were vehicles at all.

1 Like

Hey, stupid question. Wouldn’t it make sense, long term, to convert buildings into static vehicles all together? That would allow ‘armoring’ walls, built in turrets, things like that. And it would solve the generator question above while opening up other options.

1 Like

No. Currently, buildings have an extremely lightweight footprint in terms of memory and processor time; vehicles have an extremely heavyweight footprint in the same terms.

There was an extensive discussion between 4 senior devs on this topic last night on the discord server, see https://discordapp.com/channels/598523535169945603/598535887801810944/768213398541565952 and on and on for the next 6 hours.

Basically, what we expect to have happen at some point:

  • some of the vehicle code will get migrated to be usable by other entities
  • it will be possible to convert some furniture (mostly electrical appliances) into an appliance class which uses the vehicle power generation/usage code; most electrical appliances will stay furniture to minimize performance concerns but the player will have the option of making the furniture they care about into appliances.
  • most buildings will remain a collection of terrain and furniture, but again the player will have the option to take over a specific building and turn into to a facility, which again uses the vehicle power generation and usage code.

So ideally, your home base is going to be a fully powered facility with solar panels, a combustion powered generator, overhead lights, and floor lamps and machine tools as appliances. The mansion that you raid, loot, and leave will remain a collection of furniture and terrain, and the mansions’ floor lamps that you never use will remain furniture. Very light weight for performance concerns for the stuff you don’t care about, heavyweight memory and performance concerns for the stuff you do care about.


I actually caught some of that discussion. Fascinating.

Though I think some people were getting hung up on wording as to what is considered what in the way the game thinks.

Which you have corrected in this post.

But it brings up some more questions and possibe scenarios.

In an old sci fi disaster novel from the 80s, one of the characters was a manager of an electrical plant. Being a powerful and respected community figure and having heads up on the coming destruction of civilization, he called all his workers and their families to live at the power plant.

When the protaganists finally met him, they were shocked! Clean clothing, lights, all the trappings of civilization at this facility!

Of course, way the story ended up is that the survivor village that the main character was in formed an alliance with the Plant Manager and his people and agreed to share labor to repair the power lines and run power in exchange for aid in military protection and trade in farms that were coming online. Which, I’ll admit is a bit of a stretch for what yall have in mind and would be far, far end game which isn’t fleshed out nor really the focus.

But it brings the point. We already have bases like the Free Merchants that have power and some “furniture” appliances. Would those appliances be made into appliances out of the box for some things like established faction bases? Or would it be abstract like the lighted areas in some labs?

I mean, I’m sure the Free merchants would not mind you using the washer and dryer as long as you bring (or buy) your own detergent.

1 Like

The Free Merchants are going to charge you to use their washer and dryer if they let you use it; they understand the concepts of depreciation and maintenance costs. They’re capitalists and free marketeers; they have some minimal charity (the Lobby Beggars) but the Refugee Ranch shows that they’re mostly on the “work or starve” plan.

So Kevin has already said that power plants are out of scope for the intended direction of the game, and I’ve said I don’t anticipate facilitys to be larger than about 120x120 map squares (which is 5x5 overmap tiles, that’s a lot of space!).

As long as the player doesn’t have to worry about the power issues, static appliances in other people’s bases are likely to remain furniture. Especially in the case of the Free Merchants, where the dozens of NPCs are already making it one of our most processor heavy areas.

1 Like

I’ll admit that I’ve only gotten into cdda in the last 2 months but I I have checked out videos about it prior to.

While I do admit that building small stationary vehicles in your base to represent a power grid is required by game mechanics and understand that, would it be possible to make some kind of construction / vehicle tile that could connect z levels which would defeat the entire argument by allowing people to just set up miniature vehicles on the roof containing solar panels connected by these tiles to the main floor where the sentry guns and appliances would draw power from?

Like I said prior to, I am new and not sure if this is possible but thought I’d put the idea out there because it would most likely be easier than making buildings their own entities.

1 Like

You should look into jumper cables and heavy duty cables.

Also, I fully intend to make it so vehicles can have multiple z-levels themselves[1]; people have been asking for double-decker busses since forever and it’s something I want so we can have proper hot-air balloons and a better helicopter experience. It’s just something that I didn’t get done before the 0.F feature freeze.

[1] by which I mean components in the same x,y co-ordinates but different z co-ordinates; vehicles already can spawn z-levels thanks to ramps but they can’t stack.