Berserk-Games / atom-tabletopsimulator-lua

Tabletop Simulator scripting package for Atom.
Other
36 stars 27 forks source link

Fixed handling of luabundled mods with a non-default root module name #148

Closed Benjamin-Dobell closed 3 years ago

Benjamin-Dobell commented 3 years ago

The root module (entry point) in a luabundled script doesn't have an explicit filename, as it's not ever itself require'd. By default luabundle gives the root module the placeholder name __root, and that's the name this Atom plugin sticks with.

When unbundling (fetching lua scripts) we do need to grab the root module and write it to a temporary file. Prior to this PR, we assumed Atom created the TTS mod, and thus we expect to find a module named __root.

However, VSCode does not use the default module name __root, so our assumption that one exists leads to the following error when opening a mod created with the aforementioned VSCode plugin:

unknown

luabundle has built-in support retrieving the utilised root module name when unbundling, so this PR takes advantage of this functionality rather than using the hard-coded module name __root.