It is currently February 24th, 2020, 11:20 pm

Change in Lua scripting to allow dofile to be used

Changes made during the Rainmeter 4.0 beta cycle.
User avatar
Posts: 20280
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Change in Lua scripting to allow dofile to be used

Post by jsmorley »

We have changed the context of each Lua measure in your skins to be entirely local to the individual measure, to eliminate problems with defined variables or functions "bleeding" between skins when they were defined in the Initialize() function.

This has allowed us to support the use of the Lua dofile functionality, allowing you to for instance have a "toolkit" of Lua functions that you can easily share between skins in your current root config folder.
Using dofile

The dofile function can be used to include libraries or other snippets of Lua code. You must specify a full path to the dofile, using the syntax dofile('C:\PathToDoFile\SomeLua.lua'). Use GetVariable function if you want to use the #@# variable shortcut to the @Resources folder for the current config, or MakePathAbsolute if you want to have the .lua file be relative to the current skin folder.

Code: Select all

function Initalize()
Note: While a dofile you call can be anywhere on your system, be aware that if you do not put the dofile .lua file somewhere in the path to the current config, you won't be able to distribute it with your skin as a .rmskin package. A .rmskin package can only distribute the contents of a single root config folder.
You can view dofile as very similar in Lua to what @Include does in a skin...

Here is an example:
You do not have the required permissions to view the files attached to this post.
User avatar
Posts: 653
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: Change in Lua scripting to allow dofile to be used

Post by raiguard »

YES! Thank you! This is exactly what I was waiting for!

Now to redo the past month's worth of work to take advantage of this! :D
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017