Jump to content

Get a table from a .txt file


Recommended Posts

Hey dear community,

Im just looking for a way if I can get a table with a lot of values to add it on an script

I don't know if you understand me, then I will explain it better.

-- TXT Files (test.txt)

thisIsMyTable = {"value1","value2","value3","value4","value5"}

otherTable = {"value1","value2","value3","value4","value5"}

later I would like to load it on my script

  
local variableScript = {} 
local otherVariableScript = {} 
  
function getTheVariables(table1,table2) 
    if table1 then 
        variableScript = table1 
    end 
    if table2 then 
        otherVariableScript = table2 
    end 
end 
  

Thanks for reading.

Regards.

Link to comment
  • Moderators

local myContent = {

thisIsMyTable = {"value1","value2","value3","value4","value5"},

otherTable = {"value1","value2","value3","value4","value5"}

}

Read it and loadstring. As simple as that.

Yet, why aren't you just use a lua file? And more important, what is the endresult?

Or use only XML, which is in my opinion much more flexible and easy to use.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...