Function to reload a file during runtime

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
maxtrautwein
Prole
Posts: 17
Joined: Sun Apr 14, 2019 5:14 pm

Function to reload a file during runtime

Post 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!
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Function to reload a file during runtime

Post 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)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
maxtrautwein
Prole
Posts: 17
Joined: Sun Apr 14, 2019 5:14 pm

Re: Function to reload a file during runtime

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests