Skip to content

How can I write a library which has multiple files using require? #1176

Answered by SquidDev
jorolf asked this question in Q&A
Discussion options

You must be logged in to vote

I'd set package.path inside your entrypoints, so that lib is always on the path. This way both your entrypoints and other libraries only need to do require "foo"/require "bar".

So, in the case of main1.lua, something like

package.path = "lib/?.lua:" .. package.path 

local foo = require "foo"

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@jorolf
Comment options

@SquidDev
Comment options

@jorolf
Comment options

Answer selected by jorolf
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants