title: Attempt to index local (a boolean value)
body: <p>I have 2 different Lua files, <code>main.lua</code> and <code>game_model.lua</code>. I'm trying to save some details in a JSON file (I googled that using a JSON file would be the best way to save a user's settings and score), but I'm getting the following error:</p>
  
  <blockquote>
    <p>Error: File: main.lua
    Line: 11
    Attempt to index local 'game' (a boolean value)</p>
  </blockquote>
  
  <p>Why is am I getting this error and how can fix it?</p>
  
  <p>Here is the code in my <code>main.lua</code>:</p>
  
  <pre><code>--Main.lua
  
  display.setStatusBar( display.HiddenStatusBar )
  
  local composer = require( "composer" )
  local game = require("data.game_model")
  
  myGameSettings = {}
  myGameSettings.highScore = 1000
  myGameSettings.soundOn = true
  myGameSettings.musicOff = true
  myGameSettings.playerName = "Andrian Gungon"
  game.saveTable(myGameSettings, "mygamesettings.json")
  
  composer.gotoScene("scripts.menu")
  </code></pre>
  
  <p><code>game_model.lua</code> (in the <code>data</code> subdirectory) contains this code:</p>
  
  <pre><code>--game_model.lua (located at data/game_model.lua)
  
  local json = require("json")
  
  function saveTable(t, filename)
      local path = system.pathForFile( filename, system.DocumentsDirectory)
      local file = io.open(path, "w")
      if (file) then
          local contents = json.encode(t)
          file:write( contents )
          io.close( file )
          return true
      else
          print( "Error!" )
          return false
      end
  end
  
  function loadTable(filename)
      local path = system.pathForFile( filename, system.DocumentsDirectory)
      local contents = ""
      local myTable = {}
      local file = io.open( path, "r" )
      if (file) then         
           local contents = file:read( "*a" )
           myTable = json.decode(contents);
           io.close( file )
           return myTable 
      end
      return nil
  end
  </code></pre>