How do I install a cargo lock

I did a search and didn’t see anything about them but this format still confuses me some times so I might of missed a topic on this subject.

But how do cargo locks work?

I don’t think they do. Like at all. I’m not sure what they were intended for but they are either unfinished or broken.


Well that sucks. It’s a feature I asked for a few times. I wonder what it would take to get them to work.

This was implemenet last autumn and should be working.

cargo_lock is vehicle part with CARGO_LOCKING flag. This flag prevents access for npc to vehicle parts with LOCKABLE_CARGO flag. This part can be installed only to on_lockable_cargo locations (hatches, trunks, boxes).


    // Cargo locks must go on lockable cargo containers
    // TODO: do this automatically using "location":"on_mountpoint"
    if(part.has_flag("CARGO_LOCKING")) {
        bool anchor_found = false;
        for( std::vector<int>::const_iterator it = parts_in_square.begin();
             it != parts_in_square.end(); ++it ) {
            if(part_info(*it).has_flag("LOCKABLE_CARGO")) {
                anchor_found = true;
        if(!anchor_found) {
            return false;


        const optional_vpart_position vp = g->m.veh_at( p );
        if( !vp || vp->vehicle().velocity != 0 || !sees( p ) ) {
        vehicle *const veh = &vp->vehicle();
        int veh_part = veh->part_with_feature( vp->part_index(), VPFLAG_CARGO, true );
        static const std::string locked_string( "LOCKED" );
        //TODO Let player know what parts are safe from NPC thieves
        if( veh_part < 0 || veh->part_flag( veh_part, locked_string ) ) {

        static const std::string cargo_locking_string( "CARGO_LOCKING" );
        if( veh->part_with_feature( veh_part, cargo_locking_string, true ) != -1 ) {

Huh. Whaddya know.

Post limits suck.

That was my problem, I was trying to put it on a cargo space… Thanks.

Well it is a tag so just add it to the cargo space in the json.

Ehrr, problems with cargo locks are:
a) No way to lock the doors (even if you’re living in an Abrams);
b) When removing the container vehicle part, the lock doesn’t count as an attached part, so you’re left with an impression that the lock may prevent the NPCs from stealing stuff from the newly attached parts (e.g. removing a trunk, putting a cargo space instead. Looks locked, but probably isn’t)