# \[Lua\]: Degrade Buildings (Last updated on: 2018-06-19)

**URL:** <https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081>\
**Category:** The Lab\
**Tags:** mod\
**Created:** [August 3, 2017, 1:13am UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081 "2017-08-03T01:13:30Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [August 3, 2017, 1:13am UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/1 "2017-08-03T01:13:30Z")

</div>

# Description:

Walls have a chance to collapse, windows and doors can be damaged when building is generated. Also adds some graffiti to the walls.

This mod is WIP and probably rather unbalanced. All, but several buildings from `\data\json\mapgen` were updated. I will update more in future versions.

Warning: Please be aware that additional lua mapgen is rather slow, especially when logging is enabled.

# Current version:

| Date | Version | Description | Download Link |
| --- | --- | --- | --- |
| 2018-06-19 | Latest | Modified by @JT1 (see this [post](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2017-10-20/14081/27) for details) | [Dropbox](https://www.dropbox.com/s/9w687hb03wreahw/ZSLua_DegradeBuildings.zip?dl=0) |

# Older versions:

| Date | Version | Description | Download Link |
| --- | --- | --- | --- |
| 2017-10-20 | Release 3 | Without logging and profiler (Faster) | [Dropbox](https://www.dropbox.com/s/x6bf1zhyfdpknku/ZSLua_DegradeBuildings_V3.zip?dl=0) |
| 2017-09-28 | Release 2 | Without logging and profiler (Faster) | [Dropbox](https://www.dropbox.com/s/3uq28b2qgs1l8g9/ZSLua_DegradeBuildings_V2.zip?dl=0) |
| 2017-08-27 | Release 1 | Wiithout logging and profiler (Faster) | [Dropbox](https://www.dropbox.com/s/yx4lw547o5kxzmh/ZSLua_DegradeBuildings_V1.zip?dl=0) |
| 2017-08-03 | Initial | Without logging and profiler (Faster) | [Dropbox](https://www.dropbox.com/s/t7fn76jj5bg5wf6/ZSLua_DegradeBuildings_V0_NoLog.zip?dl=0) |
| 2017-08-03 | Initial | With logging and profiler (Slower) | [Dropbox](https://www.dropbox.com/s/0mvudq3lb5dngcs/ZSLua_DegradeBuildings_v0.zip?dl=0) |

# Technical info:

- Mod utilizes LUA functionality in overmap mapgen (see [https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/MAPGEN.md#25-lua](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/MAPGEN.md#25-lua)).
- You can find mod logs in `\data\mods\ZSLua_DegradeBuildings\lua\` (`ZSLua_DegradeBuildings.log` and `mapgen_degrade_building.report`).
- One can use `\data\mods\ZSLua_DegradeBuildings\lua_tools\InjectMapgenJson.lua` to process json-files with mapgens from other mods.

# Additional info:

Please also check [`dda-lua` mod](http://smf.cataclysmdda.com/index.php?topic=14861.0). `Degrade Buildings` mod will be eventually merged there.

---

<div class="post-metadata">

**Author:** ![RipRoarinBoogerPenis](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/riproarinboogerpenis/32/20_2.png) [@RipRoarinBoogerPenis](https://discourse.cataclysmdda.org/u/RipRoarinBoogerPenis)\
**Post date:** [August 4, 2017, 2:09pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/2 "2017-08-04T14:09:28Z")

</div>

Fucking sick nasty, can’t wait to try it tonight

---

<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:** [August 4, 2017, 2:31pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/3 "2017-08-04T14:31:54Z")

</div>

So lua is still in the game. I wonder why stats through skills 2 isn’t working then.

---

<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:** [August 5, 2017, 3:31pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/4 "2017-08-05T15:31:45Z")

</div>

> [@DeWolf](#):
>
> So lua is still in the game. I wonder why stats through skills 2 isn’t working then.

StatsThroughSkills mod shipped with the game is working good. Is you version of the game compiled with lua support?

---

<div class="post-metadata">

**Author:** ![RipRoarinBoogerPenis](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/riproarinboogerpenis/32/20_2.png) [@RipRoarinBoogerPenis](https://discourse.cataclysmdda.org/u/RipRoarinBoogerPenis)\
**Post date:** [August 6, 2017, 4:58pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/5 "2017-08-06T16:58:56Z")

</div>

Getting this error. Tried it in an existing world and a new one

[![](http://imagebucket.net/j649wmeqhxh1/fug.png) ](http://imagebucket.net/j649wmeqhxh1/fug.png)

---

<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:** [August 6, 2017, 6:27pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/6 "2017-08-06T18:27:36Z")

</div>

[quote=“RipRoarinBoogerPenis, post:5, topic:14081”]Getting this error. Tried it in an existing world and a new one

[http://imagebucket.net/j649wmeqhxh1/fug.png[/quote]](http://imagebucket.net/j649wmeqhxh1/fug.png%5B/quote%5D)  
You have probably some old version of CDDA which does not include Necropolis yet. Do you know version number?

---

<div class="post-metadata">

**Author:** ![RipRoarinBoogerPenis](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/riproarinboogerpenis/32/20_2.png) [@RipRoarinBoogerPenis](https://discourse.cataclysmdda.org/u/RipRoarinBoogerPenis)\
**Post date:** [August 6, 2017, 6:37pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/7 "2017-08-06T18:37:43Z")

</div>

From a couple days ago, necropolis is in but I haven’t run into any in this current world gen. Maybe it didn’t generate one and thats why I get the error? If thats the case I don’t know why it would spit me out to the main menu.

---

<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:** [August 6, 2017, 8:18pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/8 "2017-08-06T20:18:26Z")

</div>

> [@RipRoarinBoogerPenis](#):
>
> From a couple days ago, necropolis is in but I haven’t run into any in this current world gen. Maybe it didn’t generate one and thats why I get the error? If thats the case I don’t know why it would spit me out to the main menu.

The issue is you game cannot find item group `energy_weapon_armory`. It should be defined in `\data\json\itemgroups\locations.json`.

```auto
,
  {
    "id": "energy_weapon_armory",
    "type": "item_group",
    "subtype": "collection",
    "items":[
      { "group": "guns_energy", "prob": 50 },
      ["plut_cell", 30],
      ["adv_UPS_off", 20],
      ["electrolaser_conversion", 5],
      ["high_density_capacitor", 5],
      ["beam_scatterer", 5]
    ]
  },
```

It is likely that you have some mod enabled which blacklists this item group.

---

<div class="post-metadata">

**Author:** ![RipRoarinBoogerPenis](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/riproarinboogerpenis/32/20_2.png) [@RipRoarinBoogerPenis](https://discourse.cataclysmdda.org/u/RipRoarinBoogerPenis)\
**Post date:** [August 6, 2017, 8:36pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/9 "2017-08-06T20:36:12Z")

</div>

Got it working, something is fucky with my energy weapon stuff for somereason but whatever.

Love the destroyed damaged buildings. Could use more variety in the graffitti. Is there any way to disable those lua callbacks? Made a character and had to wait till daytime to check things out and just get spammed with lua callbacks.

Really excited about this, how can I add more to the graffitti?

---

<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:** [August 6, 2017, 9:32pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/10 "2017-08-06T21:32:21Z")

</div>

> [@Zhilkin](#):
>
> [quote=“DeWolf, post:3, topic:14081”]So lua is still in the game. I wonder why stats through skills 2 isn’t working then.

StatsThroughSkills mod shipped with the game is working good. Is you version of the game compiled with lua support?[/quote]  
That is the basic stats through skills which I don’t think uses lua. Basically the reason I don’t use that mod is as soon as stats update and if you start out with 0 skills then al your starting stats are dropped whereas stats through skills 2 I know doesn’t do that.

---

<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:** [August 6, 2017, 11:09pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/11 "2017-08-06T23:09:23Z")

</div>

[quote=“RipRoarinBoogerPenis, post:9, topic:14081”]Got it working, something is fucky with my energy weapon stuff for somereason but whatever.

Love the destroyed damaged buildings. Could use more variety in the graffitti. Is there any way to disable those lua callbacks? Made a character and had to wait till daytime to check things out and just get spammed with lua callbacks.

Really excited about this, how can I add more to the graffitti?[/quote]  
Graffiti strings are defined in the “\data\mods\ZSLua\_DegradeBuildings\lua\MapGen.lua”. Search for this code and add more strings as necessary:

```auto
function MapGen.RandomGraffitiString ()

  local strings = {
    "LUA rules!",
    "LOOTED",
    "X",
    "muh fukaz!",
    "Beware of Zeds",
    "Hello, Kitty!",
    "* unreadable symbols *",
    "<color_ltred>PRAY!</color>",
    "<color_red>PRAY AND SPRAY!</color>"
  }
```

Lua callbacks are defined in “\data\mods\ZSLua\_DegradeBuildings\main.lua”. They should be disabled in the NoLog version,s or either try use that version, remove callback functions or comment Log statements like this:

```auto
function MOD.on_new_player_created()
    --Log.Message("ZSLua_DegradeBuildings: main.lua: callback: on_new_player_created", true)
end

function MOD.on_skill_increased()
    --Log.Message("ZSLua_DegradeBuildings: main.lua: callback: on_skill_increased", true)
end

function MOD.on_minute_passed()
    --Log.Message("ZSLua_DegradeBuildings: main.lua: callback: on_minute_passed", true)
end

function MOD.on_day_passed()
    --Log.Message("ZSLua_DegradeBuildings: main.lua: callback: on_day_passed", true)
end
```

You can also omit second parameter of the function or set it to nil/false.

---

<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:** [August 6, 2017, 11:11pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/12 "2017-08-06T23:11:22Z")

</div>

> [@DeWolf](#):
>
> [quote=“Zhilkin, post:4, topic:14081”][quote=“DeWolf, post:3, topic:14081”]So lua is still in the game. I wonder why stats through skills 2 isn’t working then.

StatsThroughSkills mod shipped with the game is working good. Is you version of the game compiled with lua support?[/quote]  
That is the basic stats through skills which I don’t think uses lua. Basically the reason I don’t use that mod is as soon as stats update and if you start out with 0 skills then al your starting stats are dropped whereas stats through skills 2 I know doesn’t do that.[/quote]  
StatsThroughSkills shipped with the game uses lua. Somewhere in the future it will be recoded in c++, but that’s not yet true for today.

---

<div class="post-metadata">

**Author:** ![Decipher4096](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/decipher4096/32/1302_2.png) [@Decipher4096](https://discourse.cataclysmdda.org/u/Decipher4096)\
**Post date:** [August 11, 2017, 5:16pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/13 "2017-08-11T17:16:42Z")

</div>

Hey, I have a problem with this mod. I have experimental 6675 and when the game generates the world, I have this error:

 ![](http://i.imgur.com/YPy5jsx.png)  
I installed the non-log version.

I don’t want to start the game without this mod, so I’ll wait patiently for help 🙂

---

<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:** [August 11, 2017, 7:17pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/14 "2017-08-11T19:17:44Z")

</div>

[quote=“Decipher4096, post:13, topic:14081”]Hey, I have a problem with this mod. I have experimental 6675 and when the game generates the world, I have this error:  
I installed the non-log version.

I don’t want to start the game without this mod, so I’ll wait patiently for help :)[/quote]  
Please download once again (same link). There was missing comment hyphen in Mapgen.lua.

---

<div class="post-metadata">

**Author:** ![fallout2077](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/fallout2077/32/627_2.png) [@fallout2077](https://discourse.cataclysmdda.org/u/fallout2077)\
**Post date:** [August 26, 2017, 9:16pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/15 "2017-08-26T21:16:46Z")

</div>

Hey there, I’ve been having an issue starting a new game when the game tries to generate the map with this game loaded. For some reason, the forums won’t allow me to post links or attachments, so the next best thing is to provide a description of the error.  
On the DEBUG line of the error, there is a message regarding an invalid overmap terrain flag “ALLOW\_OVERRIDE”.  
The function line states: bool main\_menu::new\_character\_tab()  
File is src/main\_menu.cpp  
Line 614

---

<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:** [August 27, 2017, 5:58am UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/16 "2017-08-27T05:58:52Z")

</div>

[quote=“fallout2077, post:15, topic:14081”]Hey there, I’ve been having an issue starting a new game when the game tries to generate the map with this game loaded. For some reason, the forums won’t allow me to post links or attachments, so the next best thing is to provide a description of the error.  
On the DEBUG line of the error, there is a message regarding an invalid overmap terrain flag “ALLOW\_OVERRIDE”.  
The function line states: bool main\_menu::new\_character\_tab()  
File is src/main\_menu.cpp  
Line 614[/quote]  
Should be fixed in new V1 version.

---

<div class="post-metadata">

**Author:** ![fallout2077](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/fallout2077/32/627_2.png) [@fallout2077](https://discourse.cataclysmdda.org/u/fallout2077)\
**Post date:** [August 28, 2017, 11:54pm UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/17 "2017-08-28T23:54:56Z")

</div>

Yep, all’s well now. Thank you much!

---

<div class="post-metadata">

**Author:** ![shivIE](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@shivIE](https://discourse.cataclysmdda.org/u/shivIE)\
**Post date:** [September 28, 2017, 6:48am UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/18 "2017-09-28T06:48:03Z")

</div>

Hey there, I’ve been having an issue starting a new game when the game tries to generate the map with this game loaded.  
Could you please fix that?

 ![](https://i.gyazo.com/1127062855e7f1265a443e8d0aee8c4b.png)

---

<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:** [September 28, 2017, 7:30am UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/19 "2017-09-28T07:30:17Z")

</div>

Please try updated version:

> **[ZSLua\_DegradeBuildings\_V2.zip](https://www.dropbox.com/s/3uq28b2qgs1l8g9/ZSLua_DegradeBuildings_V2.zip?dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

**Author:** ![shivIE](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@shivIE](https://discourse.cataclysmdda.org/u/shivIE)\
**Post date:** [September 28, 2017, 8:24am UTC](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081/20 "2017-09-28T08:24:49Z")

</div>

this one works!  
Thank you for your quick and polite response.

[Next page](https://discourse.cataclysmdda.org/t/lua-degrade-buildings-last-updated-on-2018-06-19/14081.md?page=2)
