How to export from Excel to Defold?

Hi, I’m new to gamedev but I have a little idea on how it works.
I want to make a test, my game asks a question and the user picks an answer.
I want help on choosing how to store the questions.
I got an excel file like this:

+---------------+----------------+
|    Question   | Correct Answer |
+---------------+----------------+
| ¿How are you? |      Fine      |
+---------------+----------------+
|  ¿Are you 22? |       Yes      |
+---------------+----------------+

Can Defold work with excel files like python or I need to convert it to xml or something else?

1 Like

Defold doesn’t parse Excel or XML out of the box, but it’s certainly possible using a Lua module with some helper code to parse it.

My recommendation would be to convert your Excel sheet to JSON data and parse that into a Lua table using json.decode().

4 Likes

Thank you.

You can also save as CSV and parse that in Lua, which is quite easy. http://lua-users.org/wiki/LuaCsv

The best option would be to export to Lua files directly https://github.com/yanghuan/proton

5 Likes

Nice, I’ll try exporting it to a lua file, if that fails I’ll try csv or json. Thank you both.

3 Likes

What did you end up doing @Edd?

Hello I use the second lua export that you suggest and made me a table of my 78 table objects and has only at start only the return and after the table … if I require this file in a script of my objects how I access
the value of onoma of first object? I tried some things but I do not know good use of tables. Thanks for your help

code of module
return {
{
Hash = 0,
Onoma = “GUQEIO”,
Boyno = true,
Lofos = true,
Kampos = false,
Dasos = false,
Elliniki = true,
Kastro = true,
Eisodima = 1000,
Dia8esimoi = 3500
},
{…… second object of table

this way came the code this tool …

Thanks

do I have to add sth like
return M = {{….}}

I saw pairs and getmetatable but did not understand well what do
thanks

1 Like

I done code

local M ={{ ……}}
return M

now try see if needs other thing for access

thanks

I done I found the mistake when trying to access it. I start to see how do this when I read britzl saying in forum to do through data and me I was doing through go.property. After I saw here the post of sergey.lerg for csv which took me sometime to make. But I think will help me. Thanks even if I found alone forum helps has many things to find. Thanks again

1 Like