# Adding scripts during runtime

**URL:** <https://forum.defold.com/t/adding-scripts-during-runtime/2094>\
**Category:** Questions\
**Created:** [June 9, 2016, 8:09am UTC](https://forum.defold.com/t/adding-scripts-during-runtime/2094 "2016-06-09T08:09:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 9, 2016, 9:09am UTC](https://forum.defold.com/t/adding-scripts-during-runtime/2094/2 "2016-06-09T09:09:06Z")

</div>

You can load and execute scripts via other scripts at runtime. Check these posts

> [@Big List of Defold Pro Tips!](https://forum.defold.com/t/big-list-of-defold-pro-tips/1519/8):
>
> Dynamically loading and running Lua script with Defold. Thanks to @sicher References [(1)](https://forum.defold.com/t/defold-1-2-58-has-been-released/183) [(2)](https://forum.defold.com/t/dynamically-load-require-lua-files-tables-runtime/620/9) If for some reason (such as NPC dialog and movement scripting - which I’ll talk about in another post) you need to load scripts dynamically (as in you don’t know what names they are beforehand, are loading their names from another arbitrary data file) then there are some special considerations requires due of the way Defold bundles files. First put the lua scripts you want to be able to run into a sp…

> [@Big List of Defold Pro Tips!](https://forum.defold.com/t/big-list-of-defold-pro-tips/1519/48):
>
> That works! Nice! Good to know! local script = ("/main/files/level\_1.lua") local code = sys.load\_resource(script) local def = assert(loadstring(code))() print(def.layers[1].type) DEBUG:SCRIPT: tilelayer

---

_[View the full topic](https://forum.defold.com/t/adding-scripts-during-runtime/2094)._
