Plugin Structures & Naming

Hi,

I have a plugin with a number of external modules.  I saw some errors at one point (while hacking around) that made me think I may be naming my files incorrectly, so to confirm, here is my file structure currently:

[lua]

plugin

  parse.lua

  /parse

    config.lua

    debug.lua

    …

[/lua]

Everything works fine with the plugin using the local source, so I assume it is correct.  All files are based on the “plugin.parse” namespace.

But, I have also seen this naming style referenced in an error:

[lua]

plugin

  plugin_parse.lua

  /plugin.parse

    plugin_parse_config.lua

    plugin_parse_debug.lua

    …

[/lua]

Which one is correct? If any. And what is the best practice for external modules?

Thanks in advance.

Cheers.

I believe:

plugin   parse.lua   /parse     config.lua     debug.lua

is right.  To access debug.lua it would be require( “plugin.parse.debug” )

 

Rob

Rob is correct. The require statement issues you see that show underscores are from special handling. Some plugins use the now-deprecated “plugin_” instead of “plugin.” naming scheme, so it scans for that (along with .a, .so, etc. files) when trying to perform the require. Both “_” and “.” translate to a platform-independent directory marker in any case.

This assumes that you are using a modern build. We improved require statements for lua plugins back before we announced writing lua plugins on the blog.

I believe:

plugin   parse.lua   /parse     config.lua     debug.lua

is right.  To access debug.lua it would be require( “plugin.parse.debug” )

 

Rob

Rob is correct. The require statement issues you see that show underscores are from special handling. Some plugins use the now-deprecated “plugin_” instead of “plugin.” naming scheme, so it scans for that (along with .a, .so, etc. files) when trying to perform the require. Both “_” and “.” translate to a platform-independent directory marker in any case.

This assumes that you are using a modern build. We improved require statements for lua plugins back before we announced writing lua plugins on the blog.