Hello guys,
I have a project with 2 files, main and cards(the data file). From main i want read data from cards, but i dont undrstand how to do so. Hence asking for your support.
The cards file looks like this:
Event{
id = 1,
title = "title1"
}
Event{
id = 2,
title = "title2"
}
Event{
id = 3,
title = "title3"
}
Event{
id = 4,
title = "title4"
}
Event{
id = 5,
title = "title5"
}
It looks like you’re trying to store your data in something similar to JSON. Look into using one of the JSON modules here: http://lua-users.org/wiki/JsonModules
Please note: The storage format you’re using will not work perfectly.
@fikabord I don’t quite understand what you’re after, but here is what I think. You want a table created in a tab called cards and you want to read it from the tab main. If that’s the case, then I’m not sure what you want in the table. I coded 3 ways of putting the info in a table. I didn’t know if the id could be a table offset or if id was going to be a unique number.
-- this goes in the main tab
function setup()
for a,b in pairs(Event) do
print("id="..b[1],"title="..b[2])
end
print()
for a,b in pairs(Event1) do
print("id="..a,"title="..b)
end
print()
for a,b in pairs(Event2) do
print("id="..a,"title="..b)
end
end
-- this goes in the cards tab
-- create table with id and title
Event={{1,"title1"},{2,"title2"},{3,"title3"},{4,"title4"},{5,"title5"}}
-- create table with title and table offset as id number
Event1={"title1","title2","title3","title4","title5"}
-- create table with title and table offset ad id number
Event2={}
table.insert(Event2,"title1")
table.insert(Event2,"title2")
table.insert(Event2,"title3")
table.insert(Event2,"title4")
table.insert(Event2,"title5")
Sorry for being unclear. You are right david. I have a tab where i want to have some static read only data. In other words what im looking for is to have information somewhere which i can read. I dont need to be able to edit it or anything. I was thinking putting it into a table would be the easiest. I want to access the information based in different criterias.
I will see if i can get it working with yourcode dave.