# Big List of Defold Pro Tips!

**URL:** <https://forum.defold.com/t/big-list-of-defold-pro-tips/1519>\
**Category:** The Defoldmine\
**Created:** [April 12, 2016, 2:55am UTC](https://forum.defold.com/t/big-list-of-defold-pro-tips/1519 "2016-04-12T02:55:35Z")\
**Posts on this page:** 1\
**Showing post:** 8

<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:** [April 14, 2016, 2:54am UTC](https://forum.defold.com/t/big-list-of-defold-pro-tips/1519/8 "2016-04-14T02:54:39Z")

</div>

**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 special folder such as “main/extra\_scripts”. Next open your **game.project** file in a text editor and add custom\_resources with the path to your scripts. **custom\_resources** can be a path to a folder or a single file, and you can have multiple paths separated by commas.

 ![](https://forum-defold-uploads.b-cdn.net/original/1X/c25269dae86082a8557b8374965a420fefa142bb.png)

NOTE! It’s important to not have the leading slash on this one when you are selecting folders and not single files. At least for me on Windows if I have a leading slash Defold gives an access denied error.

> script = (“/path/to/script.lua”)  
> local code = sys.load\_resource(script)  
> local f = assert(loadstring(code))

See reference [(2)](https://forum.defold.com/t/dynamically-load-require-lua-files-tables-runtime/620/9) for more info.

---

_[View the full topic](https://forum.defold.com/t/big-list-of-defold-pro-tips/1519)._
