# How to change id value of item by lua script?

**URL:** <https://discourse.cataclysmdda.org/t/how-to-change-id-value-of-item-by-lua-script/9291>\
**Category:** The Lab\
**Created:** [March 31, 2015, 8:13pm UTC](https://discourse.cataclysmdda.org/t/how-to-change-id-value-of-item-by-lua-script/9291 "2015-03-31T20:13:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lagnas2000](https://avatars.discourse-cdn.com/v4/letter/l/a9adbd/32.png) [@lagnas2000](https://discourse.cataclysmdda.org/u/lagnas2000)\
**Post date:** [March 31, 2015, 8:13pm UTC](https://discourse.cataclysmdda.org/t/how-to-change-id-value-of-item-by-lua-script/9291/1 "2015-03-31T20:13:10Z")

</div>

I want to change item`s id value by lua script.

example,

Add two item on json file.

Item1`s id is "test", and item2`s id is “test\_on.”

Ok. I write lua script like below.

> function test\_off()
> 
> ```
> type = game.item_type(item)
> type["id"] = type["id"] + "_on"
> 
> ```
> 
> end
> 
> game.register\_iuse(“TESTOFF”, test\_off)

but, this script didn`t work.

How to change id value of item by lua script?

---

<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:** [April 3, 2015, 2:22am UTC](https://discourse.cataclysmdda.org/t/how-to-change-id-value-of-item-by-lua-script/9291/2 "2015-04-03T02:22:36Z")

</div>

Pretty sure there’s no way to toggle the id like that.  
It looks like you’re trying to activate or deactivate an item though, which might be possible, I’ll poke around and get back to you.

---

<div class="post-metadata">

**Author:** ![deadmerits](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/deadmerits/32/19_2.png) [@deadmerits](https://discourse.cataclysmdda.org/u/deadmerits)\
**Post date:** [June 11, 2015, 10:16am UTC](https://discourse.cataclysmdda.org/t/how-to-change-id-value-of-item-by-lua-script/9291/3 "2015-06-11T10:16:19Z")

</div>

Just checking in for Lagnas, and also wondering if lua is still supported? I remember hearing that it would only be supported as long as it was easy to maintain compatibility with previous versions.

---

<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:** [June 11, 2015, 12:57pm UTC](https://discourse.cataclysmdda.org/t/how-to-change-id-value-of-item-by-lua-script/9291/4 "2015-06-11T12:57:13Z")

</div>

BevapDin has brushed up the lua support quite a bit, though a lot more functionality needs to be wrapped by lua in order to make the lua support useful. Best way to help is to try to code something in lua and ask for things that are missing to be added.
