# How do I install a cargo lock

**URL:** <https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465>\
**Category:** The Bunker\
**Created:** [May 11, 2018, 3:30am UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465 "2018-05-11T03:30:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheKobold](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/thekobold/32/513_2.png) [@TheKobold](https://discourse.cataclysmdda.org/u/TheKobold)\
**Post date:** [May 11, 2018, 3:30am UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/1 "2018-05-11T03:30:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![darktoes](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@darktoes](https://discourse.cataclysmdda.org/u/darktoes)\
**Post date:** [May 11, 2018, 3:49am UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/2 "2018-05-11T03:49:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TheKobold](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/thekobold/32/513_2.png) [@TheKobold](https://discourse.cataclysmdda.org/u/TheKobold)\
**Post date:** [May 11, 2018, 4:19am UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/3 "2018-05-11T04:19:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [May 11, 2018, 7:05am UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/4 "2018-05-11T07:05:01Z")

</div>

This was implemenet last autumn and should be working.

> <https://github.com/CleverRaven/Cataclysm-DDA/pull/22144>

`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).

### vehicle.cpp

```auto
    // 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;
        }
}

```

### npcmove.cpp

```auto
        const optional_vpart_position vp = g->m.veh_at( p );
        if( !vp || vp->vehicle().velocity != 0 || !sees( p ) ) {
            continue;
        }
        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 ) ) {
            continue;
        }

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

```

---

<div class="post-metadata">

**Author:** ![darktoes](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@darktoes](https://discourse.cataclysmdda.org/u/darktoes)\
**Post date:** [May 11, 2018, 7:33am UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/5 "2018-05-11T07:33:47Z")

</div>

Huh. Whaddya know.

Post limits suck.

---

<div class="post-metadata">

**Author:** ![TheKobold](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/thekobold/32/513_2.png) [@TheKobold](https://discourse.cataclysmdda.org/u/TheKobold)\
**Post date:** [May 11, 2018, 2:41pm UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/6 "2018-05-11T14:41:32Z")

</div>

> [@Zhilkin](#):
>
> (hatches, trunks, boxes)

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

---

<div class="post-metadata">

**Author:** ![DeWolf](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@DeWolf](https://discourse.cataclysmdda.org/u/DeWolf)\
**Post date:** [May 11, 2018, 7:16pm UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/7 "2018-05-11T19:16:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rose](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/rose/32/1963_2.png) [@Rose](https://discourse.cataclysmdda.org/u/Rose)\
**Post date:** [May 11, 2018, 8:18pm UTC](https://discourse.cataclysmdda.org/t/how-do-i-install-a-cargo-lock/15465/8 "2018-05-11T20:18:17Z")

</div>

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)
