Skip to content

Resources ​

Dlmp ​

Fields

  • root Element — The whole-server root of the element tree.
  • resource Element — This resource as an element.
  • resource_root Element — Root of this resource's owned elements.
  • event_name string|nil — Name of the event currently being dispatched.
  • source Element|nil — Source element of the current event.
  • this_resource Element — The resource whose callback is running.
  • db DlmpDb|nil — This resource's storage; present only when resource.toml has [storage].

require ​

Loads a resource-local Lua module by name and returns its value. Names map to .lua files under the resource directory: "foo" -> foo.lua, "foo/bar" -> foo/bar.lua. The value is cached per VM, so repeated requires return the same value and run the file once. Names are case-sensitive and may use only letters, digits, _ and -, with / separating directories (no .., absolute or drive paths). Module bodies run with the SDK facade unreachable, exactly like the main script. This is not Lua's package system: no package.path, C modules or cross-resource requires.

Parameters

  • name string

Returns module any

dlmp.import ​

Imports another resource's exports as a reload-safe proxy. Allowed only for resources listed in this resource's [server] dependencies; the returned proxy resolves each <function> lazily by name at call time, so it keeps working across a reload of the imported resource. A call into an unknown or not-running target, or a callee error, raises a Lua error (catch with pcall). Arguments and results must be plain data (no functions/userdata): handles do not cross VM boundaries, so pass ids.

Parameters

  • resource string

Returns exports table<string, fun(...):...>

Documentation licensed under CC BY 4.0. DarqlineMP is not affiliated with Rockstar Games or Take-Two Interactive. Grand Theft Auto is a trademark of Take-Two Interactive Software, Inc.