No, each instance (measure) of the Lua script remains active while the skin is active. Without that, you couldn't have Lua keep track of anything between skin updates, and the Initialize() function would be useless. It would always "start over" each time the script was executed. So if you open a file in Lua, it remains open until you close it or refresh / unload the skin. It would be quite common to want that, so you could open a file for read, and then on each update, read the "next" line of the file until the end is reached.Yincognito wrote: ↑March 11th, 2020, 1:23 pmMany thanks for clearing this up, Brian. I did not look at the log with Debug mde checked, as I assumed the OP knew what he was doing more than me, since as I said, I'm not exactly an expert in Lua. I do know from my programming experience that a file needs to be closed after a read or write operation, but (incorrectly) assumed that the Lua integration in Rainmeter made such a process automatic, without needing user intervention.
So when a Lua measure is started on the load / refresh of the skin, any Initialize() function is executed, and then the script is just sitting idling, waiting for a call to any function. The most common call is to Update() which will automatically happen on every update of the measure in the skin, however Update() should not be construed as "executing the script", but just executing the Update() function. Update() is just a function like any other.
There is no call you can make, nor should there be, that says "Restart the entire script from scratch. Close all files, destroy all variables and tables, and start all over." That is only done on the refresh / unload of the skin, when the entire measure is destroyed by Rainmeter.
Nothing says you have to have an Update() function at all, you can use Inline Lua to execute and return a value or take some action on any FunctionName() call to the script. Very few Lua scripts that I write even have an Update() function anymore. It is so seldom that some automatic, regular, update of the script makes more sense than having some measure or meter that needs some work done just ask for it when it needs it.