# Way to add new iuse values in a mod?

**URL:** https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811
**Category:** The Lab
**Created:** [July 17, 2014, 5:10am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811 "2014-07-17T05:10:27Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 17, 2014, 5:10am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/1 "2014-07-17T05:10:27Z")

</div>

I was recently looking around in the json files, when I decided I’d like to add some new items, which in turn led me to wanting to create new iuse functions for a mod, without having to do any compiling or anything of that sort. Is there a way I can add a file to the mod’s folder that loads the new function? If it helps, I’d just like to copy the manhack’s script, so I could add a craftable item to spawn custom robots. I’m not a coder, so I’m don’t know what I could add, if anything, to make this work. Sorry in advance if something is unclear. Any help would be appreciated.

---

<div class="post-metadata">

### Author: ![KA101](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@KA101](https://discourse.cataclysmdda.org/u/KA101)
#### Post date: [July 17, 2014, 7:08am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/2 "2014-07-17T07:08:18Z")

</div>

If you’re adding new gear, you’re going to need to write up the iuse in C++ and compile it. The RC car mod has its iuses in main, and the items in modpack.

Sorry.

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 17, 2014, 7:19am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/3 "2014-07-17T07:19:10Z")

</div>

I may just end up compiling it, then, and thank you for the reply.

---

<div class="post-metadata">

### Author: ![CIB](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/cib/32/903_2.png) [@CIB](https://discourse.cataclysmdda.org/u/CIB)
#### Post date: [July 17, 2014, 10:07am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/4 "2014-07-17T10:07:30Z")

</div>

You can create lua iuse’s, though there’s not much documentation on that currently. I also don’t think there’s a lua API to spawn stuff yet(I probably should fix that…).

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 17, 2014, 12:27pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/5 "2014-07-17T12:27:29Z")

</div>

Is there some sort of template I could get for the lua iuse, even if it is limited to not being able to spawn things?

---

<div class="post-metadata">

### Author: ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)
#### Post date: [July 17, 2014, 3:50pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/6 "2014-07-17T15:50:25Z")

</div>

The slow/fast zombie mods use lua to manipulate monster stats. I don’t recall if there’s a lua iuse anywhere, look through the mods folder for files with .lua extensions.

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 17, 2014, 3:53pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/7 "2014-07-17T15:53:10Z")

</div>

I’ve already taken a look through the mods, and I’ve used a lot of the available files for what I already have, but it seems the fast/slow zombies mods are the only ones that have .lua files.

---

<div class="post-metadata">

### Author: ![CIB](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/cib/32/903_2.png) [@CIB](https://discourse.cataclysmdda.org/u/CIB)
#### Post date: [July 17, 2014, 7:18pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/8 "2014-07-17T19:18:23Z")

</div>

I’ll see about writing an iuse example soon™.

---

<div class="post-metadata">

### Author: ![CIB](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/cib/32/903_2.png) [@CIB](https://discourse.cataclysmdda.org/u/CIB)
#### Post date: [July 17, 2014, 9:24pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/9 "2014-07-17T21:24:14Z")

</div>

Okay, done. You’ll have to wait for the PR to land though, and then you’ll need to use latest experimental.

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

  

> <https://github.com/CIB/Cataclysm-DDA/blob/master/doc/sample_mods/lua_manhack_iuse/preload.lua>

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 18, 2014, 9:17am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/10 "2014-07-18T09:17:50Z")

</div>

Thanks for all of the help and replies so quickly, I’ll be sure to get this as soon as I can.

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 20, 2014, 3:18pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/11 "2014-07-20T15:18:00Z")

</div>

Now that I’ve done some more experimenting, I’d like to ask something more: How would I go about adding more of these entries? I’ve successfully implemented a new iuse, but don’t understand anything about lua, and was wondering if I could do this with the addition of more files or should I modify the file I’m currently using?

---

<div class="post-metadata">

### Author: ![CIB](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/cib/32/903_2.png) [@CIB](https://discourse.cataclysmdda.org/u/CIB)
#### Post date: [July 20, 2014, 4:19pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/12 "2014-07-20T16:19:26Z")

</div>

You can just copy the whole file contents into the same file, and modify the name of the lua function and the name of the IUSE in the second instance.

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 20, 2014, 4:30pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/13 "2014-07-20T16:30:40Z")

</div>

Thank you for the help and quick response. I still have two questions, though. How do I make the spawned monsters friendly, or at least non-hostile, and after the item is used it remains in the inventory, but I’d like it to delete itself.

---

<div class="post-metadata">

### Author: ![CIB](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/cib/32/903_2.png) [@CIB](https://discourse.cataclysmdda.org/u/CIB)
#### Post date: [July 21, 2014, 10:48am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/14 "2014-07-21T10:48:56Z")

</div>

Call monster:make\_friendly() after creating the monster.

Hm, strange that the item isn’t consumed. return 1 should tell the caller of the IUSE that one charge of the item should be used, but I may have misunderstood.

---

<div class="post-metadata">

### Author: ![KA101](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@KA101](https://discourse.cataclysmdda.org/u/KA101)
#### Post date: [July 21, 2014, 9:34pm UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/15 "2014-07-21T21:34:03Z")

</div>

[quote=“CIB, post:14, topic:6811”]Call monster:make\_friendly() after creating the monster.

Hm, strange that the item isn’t consumed. return 1 should tell the caller of the IUSE that one charge of the item should be used, but I may have misunderstood.[/quote]

Quickhit, haven’t looked at the specific code in question: returning 1 can be misinterpreted as returning “true”; we had a weird bug with that a few days ago elsewhere in the code. No idea if that’s the problem here, but throwing it out.

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 24, 2014, 1:05am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/16 "2014-07-24T01:05:49Z")

</div>

I’ve added the line that makes the new spawned monsters friendly, but this effect expires not too long after I’ve used the tool, creating the monster. I’m not exactly sure if the effect wears off after a period of time, or when line of sight is broken, but I don’t know what causes it, and I don’t know how I could fix it.

---

<div class="post-metadata">

### Author: ![CIB](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/cib/32/903_2.png) [@CIB](https://discourse.cataclysmdda.org/u/CIB)
#### Post date: [July 24, 2014, 5:12am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/17 "2014-07-24T05:12:33Z")

</div>

Try monster.friendly = -1, then.

---

<div class="post-metadata">

### Author: ![Survivor\_Kane](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/survivor_kane/32/336_2.png) [@Survivor\_Kane](https://discourse.cataclysmdda.org/u/Survivor_Kane)
#### Post date: [July 28, 2014, 1:55am UTC](https://discourse.cataclysmdda.org/t/way-to-add-new-iuse-values-in-a-mod/6811/18 "2014-07-28T01:55:32Z")

</div>

Setting monster friendly to -1 worked perfectly, thank you.
