title: How do I use external files as tables in Lua?
body: <p>I want to make a program that chooses a random monster from a list, give the user a list of usable weapons, and allows them to choose which weapon to use. I want to use external files to store data for the weapons instead of adding the tables in the Lua file itself. I have tried using Lua files to store the data as a table.</p>
  
  <p>I have a file called sword.lua in the same folder as the program I want to access it's information. It contains</p>
  
  <pre><code>sword = {'sword', '10', '1', '100'}
  </code></pre>
  
  <p>I am trying to access the information using </p>
  
  <pre><code>wep = io.open("sword.lua", "r")
  print(wep:read("*a"))
  print(wep[1])
  </code></pre>
  
  <p>The first print returns all of the text in the file which is</p>
  
  <pre><code>"sword = {'sword', '10', '1', '100'}" 
  </code></pre>
  
  <p>and the second is supposed to return the first item in the table. Every time I do this, I get a nil value from the second print. The file is being read, as indicated by the first print listing the text, but how do I make it read the file as a table that I can use in my program.</p>