Page 1 of 1

Function to reload a file during runtime

Posted: Thu Mar 19, 2020 6:56 am
by maxtrautwein
Hey! I need some help:
I have a function that load a .csv file, and this file is constantly changing outside the lua/love application. So I want to be able to reload the file each time to see the changes by pressing the key 'X' for example. I've already tried LICK but to reload we have to save the .lua file again so it's not directly on the application.

I am looking for a function that can reload a file during runtime while staying on the application.

You can tell me if it's not clear (english is not my native language)

Thank you very much for your answers!

Re: Function to reload a file during runtime

Posted: Thu Mar 19, 2020 10:52 am
by zorg
Since it's a csv file and not a lua file, you should be able to just read the contents of the file again by running the function you wrote to load and parse the file itself.

Also, hopefully you're not talking about automatically detecting changes in the file itself, since you said that you'd press a button to "reload" it. (that is also possible though, with storing the last modified date, and checking that against the same variable love.filesystem.getInfo can return)

Re: Function to reload a file during runtime

Posted: Fri Mar 20, 2020 9:47 am
by maxtrautwein
Thank for the reply!

It works, it was totally easy I don't why I thought I needed to do something else haha.

I just had to recall the function.