Moonflower-Mods / allium

Lua script loader and API for easy Minecraft modding
MIT License
44 stars 9 forks source link

Lua "require" reimplementation #12

Closed hugeblank closed 2 years ago

hugeblank commented 2 years ago

Require gets a string passed in. The string should be one of three things:

  1. Another scripts identifier require("script-id"). This would give whatever is returned by the scripts entrypoint.
  2. A path within the script calling require require("path.to.library"). This would be a path relative to the script calling require. It would give whatever's returned by the script on execution.
  3. A mods provided identifier require("mod-id"). This would give whatever is returned by a mod providing an external API for use within allium. (If you are a developer and do this, I love you.)

I recall require stores loaded packages in a table packages.something... To keep compat with Lua we'll have to respect this. Shouldn't be to bad. Simply mentioning it here as a reminder to anyone attempting an implementation (ie: me)