Hello there. I am a begginer “Default” user and my question may be simple, however I don’t understand how to do this simple thing. For example, I have a file with 2000+ lines of characteristics (1 per line) and I need to select 1 of them. I think that I don’t need to register them all in an array and select them via array[math.random(#array)]. If it is possible to use some databases instead of the usual ones .txt files, I would be glad to know about them, and how to use them through the code. Thank you in advance.
Check out the Lua io library:
https://www.lua.org/pil/21.1.html
Defold ref:
Here’s an actual example:
Thank you, but I still don’t understand which filename I need to specify in io.open() and where I need to save the file so that I can read it with a script (on Android) ^-^
First of all, does it need to be a txt file? If it’s static data it would probably be better living in a Lua module instead.
Otherwise, check out this:
And this:
No, it can be anything, I meant it when I wrote about databases. Yes, the data is static, if you mean that they do not change during the game. If so, please tell me where I can get acquainted with the Lua module
Yes, modules sound perfect for this and it’s how I handle data in my games.
2 Likes