It is currently April 26th, 2024, 4:49 pm

Quick Lua Question Regarding How Its Executed In Rainmeter

Discuss the use of Lua in Script measures.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Quick Lua Question Regarding How Its Executed In Rainmeter

Post by santa_ryan »

Does Lua force kill itself if you send a SKIN:Bang(!RainmeterRefresh) or what happens to the lua script? Does it continue to run til its completion?

While my original problem (Not actually mentioned here) is solved, Im still curious.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Quick Lua Question Regarding How Its Executed In Rainmet

Post by jsmorley »

I don't want to go out on a limb on what technically is going on under the covers, but my experience with how Lua and Rainmeter interact is:

1) When the skin is loaded or refreshed, the stuff in PROPERTIES and Initialize in the script are evaluated / executed once. This information is maintained in memory while the skin is loaded. They are only re-evaluated on a refresh (or unload / load of course) of the skin.

2) All the code in Update is executed on each update of the skin. (or UpdateDivider of the measure) The entire script is executed, then control is returned to Rainmeter. Any !bangs or other interactions between Lua and Rainmeter in effect happen in a "batch" on each update. What this means is that you can't have a Lua script that for instance does "a" to a skin, then waits for some period of time and does "b" to the skin. Both "a" and "b" will happen at once, and any "sleep" in a Lua script will just hang Rainmeter for the sleep period.

3) Since the code in Update is done more or less in a batch mode on each Rainmeter update, if you send a bang to refresh the skin, or even one to exit Rainmeter, all the Lua code in Update will execute before Rainmeter sees the bang on the next Rainmeter update. Then on a refresh the entire Lua script is restarted, including re-reading and executing the stuff in PROPERTIES and Initialize.