# Cataclysm-DDA-LUA (Updated on 2017-11-29)

**URL:** https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117
**Category:** The Lab
**Tags:** mod
**Created:** [August 11, 2017, 1:04pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117 "2017-08-11T13:04:23Z")
**Posts on this page:** 15
**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 11, 2017, 1:04pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/1 "2017-08-11T13:04:23Z")

</div>

# Description:

Cataclysm-DDA-LUA is collection of LUA mods for [Dark Days Ahead](http://en.cataclysmdda.com/).

# Last updated on:

2017-11-29

# Contents:

## dda-lua

Shared library mod for easier creation of LUA mods.

## dda-lua-achievements

Mod that adds following achievements:

- _not implemented yet_.

## dda-lua-fun

Mod that adds following fun:

- select character nationality on game start and receive several bonus items - [suggested on the forums](http://smf.cataclysmdda.com/index.php?topic=3310.msg303300#msg303300).

## dda-lua-items

Mod that adds following items:

- `atomic_entity_scanner` - highlights items and creatures around player character;
- `atomic_earthquake_generator` - makes rubbles around player character;
- `atomic_flamethrower` - bursts fire in selected direction.

## dda-lua-mapgen

Mod that adds following mapgen:

- _not implemented yet_.

## dda-lua-skills

Mod that adds following skills:

- `athletics` - gives +2 base speed points per 1 skill level, based on `squares_walked` (practices by 1 skill point per 10 tiles traversed with at least 1 skill point).

## dda-lua-traits

Mod that adds following traits:

- `TOURETTE` - shouts bad words when not under medication (`xanax`);
- `NIGHTMARES` - you see bad dreams when not under medication (`ambien`);
- `NUDIST` - +2 to all attributes when naked;
- `DEAFNESS` - you are totally deaf and cannot hear anything - [suggested on the forums](http://smf.cataclysmdda.com/index.php?topic=3310.msg302708#msg302708);
- `BLINDNESS` - you are totally blind and cannot see anything.

# Todo list:

## dda-lua

- enhance capabilities (add `mapgen`, `menu`, `config`);
- update figlet/ascii intro;
- implement global configuration menu;
- optimize `figlet` data;
- optimize container handling in `function_players` data;
- make profiling and optimize code;
- make use of `lifetime_stats` (see [https://github.com/CleverRaven/Cataclysm-DDA/pull/21607](https://github.com/CleverRaven/Cataclysm-DDA/pull/21607)).

## dda-lua-achievements

- add achievements infrastructure to `dda-lua-achievements`;
- add achievements (`squares_walked`, `cash`, `damage_taken`, `damage_healed`, `headshots`, `skill_level`, `attribute`, `recipes_known`, `get_naked`, `speed`).

## dda-lua-fun

- rewrite code to make use of `dda-lua`;
- add more nationalities, review bonus items and quantities;
- rotting food and corpses create stench clouds that reduce morale. Wearing mouth protection reduces the effect. Perfume and incense can be used for an opposite effect - see [http://smf.cataclysmdda.com/index.php?topic=3310.msg300514#msg300514](http://smf.cataclysmdda.com/index.php?topic=3310.msg300514#msg300514).
- hygiene (you make filthier each turn and must wash/clean yourself with occassionally. filthy gear matters)

## dda-lua-items

- rewrite code to make use of `dda-lua`;
- implement solar powered items;
- implement ascii photo-gallery for camera.

## dda-lua-mapgen

- add mapgen infrastructure to `dda-lua-mapgen`;
- rewrite code to make use of `dda-lua`;
- implement some buildings (merge from [http://smf.cataclysmdda.com/index.php?topic=14231.msg300728#msg300728](http://smf.cataclysmdda.com/index.php?topic=14231.msg300728#msg300728));
- implement building degradation (merge from [http://smf.cataclysmdda.com/index.php?topic=14825.0](http://smf.cataclysmdda.com/index.php?topic=14825.0)).

## dda-lua-skills

- change `athletics` skill to control `stamina` and/or `fatigue`;
- rebalance `athletics` skill practice amount per `squares_walked`.

## dda-lua-traits

- change `NUDIST` trait to affect morale;
- change `NIGHTMARES` trait to affect morale after awake;
- add more nightmare images to `NIGHTMARES` trait;
- add `ALHOHOLIC` trait - Every time you find alcohol, your character has a % chance to automatically pick it up and start drinking - [http://smf.cataclysmdda.com/index.php?topic=3310.msg300936#msg300936;](http://smf.cataclysmdda.com/index.php?topic=3310.msg300936#msg300936;)
- add `HYPOCHONDRIA` trait - Whenever physically injured or affected by Flu, Infection, Poison or Shroom sickness, character gains a -50 morale penalty until their condition improves to normal - [http://smf.cataclysmdda.com/index.php?topic=3310.msg302481#msg302481](http://smf.cataclysmdda.com/index.php?topic=3310.msg302481#msg302481).

# Screenshots:

![](https://gifyu.com/images/output_8XgSQx.gif)

 ![](http://i.imgur.com/sq9FK0z.gif)

# Links:

- [Repository](https://github.com/ZhilkinSerg/Cataclysm-DDA-LUA)
- [Releases](https://github.com/ZhilkinSerg/Cataclysm-DDA-LUA/releases)
- [Future plans](https://github.com/ZhilkinSerg/Cataclysm-DDA-LUA#todo-list)
- [Latest version](https://github.com/ZhilkinSerg/Cataclysm-DDA-LUA/releases/latest)

---

<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 11, 2017, 2:36pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/2 "2017-08-11T14:36:34Z")

</div>

Ok I was going to say something else but I see why this needs to be a lua mod since the jsons only allow for skill descriptions and not the addition of new skills at least not in that way. Now on that note I really like the idea of athletic the other traits look good too.

---

<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 11, 2017, 2:42pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/3 "2017-08-11T14:42:07Z")

</div>

With the achievements, would a highscore list be doable?

---

<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 12, 2017, 6:51pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/4 "2017-08-12T18:51:51Z")

</div>

> [@RipRoarinBoogerPenis](#):
>
> With the achievements, would a highscore list be doable?

We’ll see.

---

<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 13, 2017, 12:44am UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/5 "2017-08-13T00:44:21Z")

</div>

How long should I expect the athletics skill to go up?

---

<div class="post-metadata">

### Author: ![Alec\_White](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/alec_white/32/509_2.png) [@Alec\_White](https://discourse.cataclysmdda.org/u/Alec_White)
#### Post date: [August 13, 2017, 1:34am UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/6 "2017-08-13T01:34:50Z")

</div>

Damn Zhilkin this stuff is fun. Specially the athletics and tourette.

---

<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 13, 2017, 6:40am UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/7 "2017-08-13T06:40:09Z")

</div>

> [@DeWolf](#):
>
> How long should I expect the athletics skill to go up?

athletics should be practiced by 1 point per 10 tiles traversed, but for at least 1 point.

```auto
  local squares_per_train = 10 --TODO: make this variable configurable or implement some smarter formula for `trained_amount`
  local trained_amount = squares_walked_delta / squares_per_train

  if (trained_amount > 0 and trained_amount < 1) then

    trained_amount = 1

  end
  MOD.PracticeSkill("athletics", trained_amount)
```

---

<div class="post-metadata">

### Author: ![Rock](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/rock/32/626_2.png) [@Rock](https://discourse.cataclysmdda.org/u/Rock)
#### Post date: [August 13, 2017, 10:29am UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/8 "2017-08-13T10:29:08Z")

</div>

Love the nightmare mod, I like the idea of showing a visualization of my characters night terrors. I hope you add more additions to the nightmares so I can see cool new horrors to be explored while dreaming!

---

<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 13, 2017, 4:10pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/9 "2017-08-13T16:10:08Z")

</div>

> [@Zhilkin](#):
>
> [quote=“DeWolf, post:5, topic:14117”]How long should I expect the athletics skill to go up?

athletics should be practiced by 1 point per 10 tiles traversed, but for at least 1 point.

[code]  
local squares\_per\_train = 10 --TODO: make this variable configurable or implement some smarter formula for `trained_amount`  
local trained\_amount = squares\_walked\_delta / squares\_per\_train

if (trained\_amount \> 0 and trained\_amount \< 1) then

```
trained_amount = 1

```

end  
MOD.PracticeSkill(“athletics”, trained\_amount)  
[/code][/quote]  
Actually if say I think the lua failed to load or something like that what would I do to try and re activate the lua. I ask cause since I first used it on a save without it causing an aparantly critical load failure it gave an error but it did not show up any more later. Anyways I ask because I have literally walked miles and athletics did not tick once. Maybe I need to turn them off and back on again.

---

<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 13, 2017, 5:05pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/10 "2017-08-13T17:05:20Z")

</div>

> [@DeWolf](#):
>
> [quote=“Zhilkin, post:7, topic:14117”][quote=“DeWolf, post:5, topic:14117”]How long should I expect the athletics skill to go up?

athletics should be practiced by 1 point per 10 tiles traversed, but for at least 1 point.

[code]  
local squares\_per\_train = 10 --TODO: make this variable configurable or implement some smarter formula for `trained_amount`  
local trained\_amount = squares\_walked\_delta / squares\_per\_train

if (trained\_amount \> 0 and trained\_amount \< 1) then

```
trained_amount = 1

```

end  
MOD.PracticeSkill(“athletics”, trained\_amount)  
[/code][/quote]  
Actually if say I think the lua failed to load or something like that what would I do to try and re activate the lua. I ask cause since I first used it on a save without it causing an aparantly critical load failure it gave an error but it did not show up any more later. Anyways I ask because I have literally walked miles and athletics did not tick once. Maybe I need to turn them off and back on again.[/quote]  
There is some initialization which is done on new player creation - some zero values are being saved withing the player.

PARAM.save(“squares\_walked\_total”, 0)  
PARAM.save(“stats\_squares\_walked”, 0)  
PARAM.save(“speed\_bonus”, 0)

If you add mod to existing save you can try to run these statements in debug lua console.

You can also can provide error text/screenshot or provide savegame, so I could check what’s wrong.

---

<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 14, 2017, 1:47am UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/11 "2017-08-14T01:47:42Z")

</div>

data/mods//dda-lua-skills/main.lua:147: attempt to perform arithmetic on a nil value (local ‘squares\_walked\_prev’)

That is the error I got when I tried those commands you gave.

EDIT:never mind skill is increasing and my current speed is now 102 so huzzah.

---

<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 14, 2017, 5:55am UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/12 "2017-08-14T05:55:14Z")

</div>

Great

---

<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: [October 2, 2017, 7:00pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/13 "2017-10-02T19:00:24Z")

</div>

Just added atomic flamethrower which bursts fire in selected direction. Works best with realtime progression turned on.

[[Album] CDDA Flamethrower in LUA ![](https://i.imgur.com/sq9FK0z.jpg?fb "CDDA Flamethrower in LUA") ](https://imgur.com/a/K5beX)

---

<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: [October 2, 2017, 7:02pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/14 "2017-10-02T19:02:00Z")

</div>

> [@Zhilkin](#):
>
> Just added atomic flamethrower which bursts fire in selected direction. Works best with realtime progression turned on.

Realtime progression?

---

<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: [October 2, 2017, 7:39pm UTC](https://discourse.cataclysmdda.org/t/cataclysm-dda-lua-updated-on-2017-11-29/14117/15 "2017-10-02T19:39:09Z")

</div>

> [@DeWolf](#):
>
> [quote=“Zhilkin, post:13, topic:14117”]Just added atomic flamethrower which bursts fire in selected direction. Works best with realtime progression turned on.

Realtime progression?[/quote]

17th row in General tab in Options menu
