import { FileTree, Tabs, Tab, Callout } from 'nextra/components' # Modules At this point you know how the most important built-in libraries in Lune work and how to use them, and your code is probably getting longer and more difficult to read. Splitting your code into multiple files can help you stay organized. Modularizing your code and splitting it across several files in Lune is different from other versions of Lua and Luau, and more similar to how things work in other languages such as JavaScript. ## Example File Tree Let's use this directory & file tree structure for our examples: ```lua copy filename="main.luau" local sibling = require("sibling") local modules = require("modules") print(sibling.Hello) --> World print(modules.Module.Foo) --> Bar print(modules.Module.Fizz) --> Buzz print(modules.Sibling.Hello) --> World ``` ```lua copy filename="sibling.luau" return { Hello = "World", } ``` ```lua copy filename="modules/init.luau" return { Module = require("module"), Sibling = require("../sibling"), } ``` ```lua copy filename="modules/module.luau" return { Foo = "Bar", Fizz = "Buzz", } ``` ## File Require Statements Let's decipher these files and what they are doing: - The `main` script requires `sibling` and `modules` next to it - The `modules/init` script requires `module` next to it, and `sibling` going up one directory using `../` In the above `require` statements, we can see that are relative to the file that they are in, and in Lune this is always the case, except for built-in libraries, which always start with an at sign (`@`). **Q:** Wait, hold on... The `main` script requires the _**directory**_ called `modules`?
**A:** Yep, that's right. The file name `init` is special, and putting a file named `init.luau` in a directory will let you use `require` directly on the directory. Similar to `index.js` in JavaScript or `mod.rs` in Rust.