Module package_extras

Extra functionality for Lua's package library.

Patch the package.loaders/package.searchers to use searchpath, so that require can find files relative to the res:// and executable folder.

Functions

package.searchpath (name, path[, separator="."[, replacement="/"]]) Searches for the given name in the given path.

Fields

package.cpath When Lua PluginScript is loaded, package.cpath is either replaced, appended or prepended by the paths in lua_pluginscript/package_c_path/templates project setting.
package.path When Lua PluginScript is loaded, package.path is either replaced, appended or prepended by the paths in lua_pluginscript/package_path/templates project setting.


Functions

package.searchpath (name, path[, separator="."[, replacement="/"]])
Searches for the given name in the given path.
Similar to Lua 5.2+ package.searchpath, but using Godot Files instead, so that paths like res:// and user:// are supported.

! characters in path templates are replaced by the directory of the game/app executable when running a standalone build (when OS:has_feature("standalone")) or by the project's resource path otherwise (ProjectSettings:globalize_path("res://")).

Parameters:

  • name
  • path
  • separator (default ".")
  • replacement (default "/")

Returns:

    string Found file name

Or

  1. nil
  2. string Error message

Fields

package.cpath
When Lua PluginScript is loaded, package.cpath is either replaced, appended or prepended by the paths in lua_pluginscript/package_c_path/templates project setting.

The chosen behavior depends on the lua_pluginscript/package_c_path/behavior project setting.

Default paths are !/?.dll and !/loadall.dll on Windows, !/?.so and !/loadall.so elsewhere.

See also:

package.path
When Lua PluginScript is loaded, package.path is either replaced, appended or prepended by the paths in lua_pluginscript/package_path/templates project setting.

The chosen behavior depends on the lua_pluginscript/package_path/behavior project setting.

Default paths are res://?.lua, res://?/init.lua and 'res://addons/godot-lua-pluginscript/build/?.lua'.

See also:

generated by LDoc 1.4.6 Last updated 2023-01-04 08:52:34