import
Runs a resource's module in this script's Lua state, once per state, and gives back what it returned. The globals the module set become this script's.
Parameters
| Name | Type | Description |
|---|---|---|
| module | string|table | "@resource/module", or "@resource" for its main module. A table of global names limits what is handed over to those names: import { "a", "b" } "@resource/module". |
Returns
What the module returned, or true if it returned nothing. With a table, a function that takes the module's name and does the import.
Every *.lua under a resource's modules/ is a module, with nothing in meta.xml. Those in modules/server/ are server-only and never sent, those in modules/client/ client-only, and the rest shared. The name is the path under modules/ without .lua and without a leading server/ or client/; a side's own file wins over a shared one of the same name.
On the server, importing a resource that is not running starts it first. On the client, the resource must already be loaded on this client. A second import of the same module in the same state does not run it again; it only hands over the globals and the return value again.
Example
local sql = import "@lp_database/sql"
import { "formatMoney" } "@utils"
outputDebugString(formatMoney(1500))false: a resource or module that does not exist, a module of the other side, one that does not compile, one imported again while it runs, or a name in the table the module does not define.