Comments (3)
This was designed for luarocks and I'd prefer to keep .lua files out of the root folder and into their own namespace. With that requirement, is there anything else we can do to make this cleaner?
from say.
Check out the require() function, it will try a list of locations based upon the name of the required module.
Using zerobrain studio;
require('somemodule')
[string "require('somemodule')"]:1: module 'somemodule' not found:
no field package.preload['somemodule']
no file 'lualibs/somemodule.lua'
no file 'lualibs/somemodule/somemodule.lua' <----
no file 'lualibs/somemodule/init.lua' <----
no file 'lualibs/somemodule/somemodule/somemodule.lua'
no file 'lualibs/somemodule/somemodule/init.lua'
no file '.\somemodule.lua'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\lua\somemodule.lua'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\lua\somemodule\init.lua'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\somemodule.lua'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\somemodule\init.lua'
no file 'C:\Users\Public\Lua\5.1\lua\somemodule.luac'
no file 'bin/somemodule.dll'
no file 'bin/clibs/somemodule.dll'
no file '.\somemodule.dll'
no file '.\somemodule51.dll'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\somemodule.dll'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\somemodule51.dll'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\clibs\somemodule.dll'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\clibs\somemodule51.dll'
no file 'C:\Users\Public\Lua\ZeroBrainStudio\loadall.dll'
This is the list searched for the module, check the ones I marked with the '<----'
If you keep it in the 'say' folder, but name it either 'say.lua' or 'init.lua'
\say\say.lua
\say\init.lua
then you can call the module with;
local s = require('say')
My initial post above should probably have been clearer.
from say.
I already included the filename change in the pull request. It will work properly with LuaRocks (though I haven't updated the rockspec file)
from say.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from say.