Modules
Metadata
Shared

Shared

Metadata is a module that allows you to read metadata attributes from a resource's fxmanifest.lua file using the native GetResourceMetadata function.

lib.metadata

lib.metadata(keys, resourceName)

Parameters

  • keys string | table: the attribute key(s) you want to read
  • resourceName string: the name of the resource (optional, defaults to current resource)

Return

  • string: the value of the attribute (when keys is a string)
  • table: a table containing key-value pairs (when keys is a table)
  • nil: if the attribute doesn't exist

Examples

Single attribute

author 'Trippler'
version '1.0.0'
repository 'https://github.com/TripplerScripts/tr_lib'
local version = lib.metadata('version', 'tr_lib')
print(version) -- output: 1.0.0
 
local author = lib.metadata('author', 'tr_lib')
print(author) -- output: Trippler

Multiple attributes

local info = lib.metadata({'version', 'repository', 'author'}, 'tr_lib')
print(info.version)     -- output: 1.0.0
print(info.repository)  -- output: https://github.com/TripplerScripts/tr_lib
print(info.author)      -- output: Trippler

Current resource (no resource name specified)

local version = lib.metadata('version')
print(version) -- output: version of the current resource