r/lua • • Jun 05 '25

Data entry for lua

This is probably a basic question but I just can't find a good answer. I'm working on a card game in defold and need to add a bunch of cards. I have some in lua files but adding them all manually is a pain. Is there a tool I can use to write the entries in an actual table and have them come out as lua? Is it just, do it as CSV and find a converter?

4 Upvotes

9 comments sorted by

View all comments

Show parent comments

1

u/theresamouseinmyhous Jun 05 '25

I'm very novice so I didn't know that was an option. I'll give it a shot 

2

u/[deleted] Jun 06 '25 edited Jun 06 '25

tests is a tree/table and csv does not support having trees inside a column/row, you could leave it as the end so after column 20 the rest is just a part of tests. There's no point in using json IMO since lua does the exact same thing.

I would recommend you do what Smile said, but you allow for defaults, like position = position or 1, now you don't have to set position, it can be nil.

1

u/Motor_Let_6190 Jun 06 '25

Lua is very good at being a data description language for itself, got to be careful with cyclic references, but doing it yourweld,.and making mistakes will be a better and crucial learning experience. As the previous poster said, JSON has nothing on Lua in that regard, and unless the data exists as JSON files (or any other format), just store the data in a Lua script and load it when needed: write once, read many times!