title: Issue using "require()" in Lua, need help understanding why it won't work
body: <p>I'm learning to use Lua, more specifically - the love2d libraries, and decided to try and organize my project by utilizing lua's 'require()' function. I know about package.path and the way it is used, but even after seemingly doing everything correctly, using a function from the external script returns 'true'. Here's the details:</p>
  
  <pre><code>-- Package.Path edit
  package.path = package.path .. ';scripts/?.lua' 
  
  -- Module requiring and inserting
  -- Map module
  mapModule = require('mapscript')
  </code></pre>
  
  <p>Continuing this further into the program, inside love.load():</p>
  
  <pre><code> mapModule.map_generate(tilemap_1, MAP_PROPERTIES)
  </code></pre>
  
  <p>The <code>map_generate()</code> function in question shouldn't be returning anything, it is simply a bunch of loops to create a square matrix of values, which takes two arguments. I don't think it is as important, so to keep this post tidier I am linking a pastebin: 
  <a href="https://pastebin.com/ZaE7Tzpa" rel="nofollow noreferrer">https://pastebin.com/ZaE7Tzpa</a></p>
  
  <p>The file tree is the following:</p>
  
  <pre><code>`-main.lua
   -conf.lua
   -run.bat (to quickly be able to run the main.lua)
   -scripts 
     -- mapscript.lua
   -assets
  </code></pre>
  
  <p>`</p>
  
  <p>When running the file I recieve the following error:</p>
  
  <blockquote>
    <p>main.lua: 51: attempt to index global 'mapModule' (a boolean value)</p>
  </blockquote>
  
  <p><strong>HOWEVER</strong> when using <code>map_generate()</code> directly instead, the issue disappears.</p>
  
  <p>If I understand correctly, the error means that the require() has failed to load the script. Why does this happen? Why does using the function directly work instead? What's the point of the local variable you bind the require to?</p>