It is currently March 28th, 2024, 10:12 pm
Using a variable in !ActivateConfig bang
-
- Posts: 8
- Joined: January 31st, 2017, 3:18 pm
Re: Using a variable in !ActivateConfig bang
Yeah I knew #SKINPATH# would always work, the rest of the built in variables do so i would not have thought that it wouldnt. BUT, due to your very helpful use of the substitute option, and the MeasureFileView measure you gave me, i have figured out my problem and fixed it. Thank you jsmorley!
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Using a variable in !ActivateConfig bang
Glad to help!al97729 wrote:Yeah I knew #SKINPATH# would always work, the rest of the built in variables do so i would not have thought that it wouldnt. BUT, due to your very helpful use of the substitute option, and the MeasureFileView measure you gave me, i have figured out my problem and fixed it. Thank you jsmorley!
-
- Posts: 8
- Joined: January 31st, 2017, 3:18 pm
Re: Using a variable in !ActivateConfig bang
Do you have any advice regarding activating all skins in a certain folder?
I have made my skin so you only need to copy and paste it to make a new instance, and i want to be able to run every skin inside of a folder, each in their own subfolder. But i am unsure how to go about going through all folders in a folder and activating each skin.
I have made my skin so you only need to copy and paste it to make a new instance, and i want to be able to run every skin inside of a folder, each in their own subfolder. But i am unsure how to go about going through all folders in a folder and activating each skin.
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Using a variable in !ActivateConfig bang
I would not use FileView for this. It's really not designed for "open ended" questions like this. Give me a minute and I will work up something using RunCommand and Lua, that will do what you want.al97729 wrote:Do you have any advice regarding activating all skins in a certain folder?
I have made my skin so you only need to copy and paste it to make a new instance, and i want to be able to run every skin inside of a folder, each in their own subfolder. But i am unsure how to go about going through all folders in a folder and activating each skin.
Hint: dir /B /S *.ini
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Using a variable in !ActivateConfig bang
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureGetDir "Run"]
[Variables]
MyPath="#SKINSPATH#Illustro\"
[MeasureGetDir]
Measure=Plugin
Plugin=RunCommand
Parameter=dir /B /S "#MyPath#*.ini"
State=Hide
FinishAction=[!CommandMeasure MeasureLoadConfigs "LoadConfigs()"]
[MeasureLoadConfigs]
Measure=Script
ScriptFile=#CURRENTPATH#LoadConfigs.lua
UpdateDivider=-1
[MeterDummy]
Meter=String
Code: Select all
function Initialize()
-- Get a handle to the RunCommand Measure
measureGetDir = SKIN:GetMeasure('MeasureGetDir')
-- Get the value of the built-in #SKINSPATH# variable
skinsPath = SKIN:GetVariable('SKINSPATH')
end
function Update()
end
function LoadConfigs()
-- Get the current string value of the RunCommand measure
dirString = measureGetDir:GetStringValue()
-- Remove #SKINSPATH# from result
dirString = string.gsub(dirString, skinsPath, '')
-- Get a count of how many configs there are, by counting ".ini"
_, fileCount = string.gsub(dirString, '%.ini', '')
-- Use a function to break the long string from RunCommand into a table of separate lines
linesTable = LineSplit(dirString)
-- Loop through the table
for i = 1, fileCount do
-- Find the last "\" character in the line
lastSlash = string.find(linesTable[i], '\\[^\\]*$')
-- Get the config name, based on the lastSlash value
configName = string.sub(linesTable[i], 1, lastSlash-1)
-- Get the .ini file name, based on the lastSlash value
fileName = string.sub(linesTable[i], lastSlash+1)
-- Fire an !ActivateConfig bang for this config / file
SKIN:Bang('!ActivateConfig', configName, fileName)
end
end
function LineSplit(str)
local t = {}
local function helper(LineSplit) table.insert(t, LineSplit) return '' end
helper((str:gsub('(.-)\r?\n', helper)))
return t
end
Note for Lua geeks. While it would be a bit easier to output the RunCommand to a text file, and open and parse that file in Lua, that won't work. The output of DIR in cmd.exe is UTF-16, which cannot be loaded and read properly by Lua. So we have to use the raw string value of RunCommand in memory, where file "encoding" isn't an issue. However, since that is one long string with embedded carriage return / linefeed characters, we have to use that lines() function to break it up.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 8
- Joined: January 31st, 2017, 3:18 pm
Re: Using a variable in !ActivateConfig bang
Edit: Ignore that, i somehow accidentally renamed my folder (i suspect my friend did it, but he says he didnt...), its working now though.
Thank you very much for this!
I have been meaning to learn Lua for a while, more and more things seem to be using it now, i wanted to Make some mods for Don't starve but ive not gotten around to doing it yet. Do you know of any good tutorials that you'd recommend?
Thank you very much for this!
I have been meaning to learn Lua for a while, more and more things seem to be using it now, i wanted to Make some mods for Don't starve but ive not gotten around to doing it yet. Do you know of any good tutorials that you'd recommend?
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Using a variable in !ActivateConfig bang
Tutorials for Lua are thin on the ground really, and most of them are not really all that good. You might start here:al97729 wrote:Edit: Ignore that, i somehow accidentally renamed my folder (i suspect my friend did it, but he says he didnt...), its working now though.
Thank you very much for this!
I have been meaning to learn Lua for a while, more and more things seem to be using it now, i wanted to Make some mods for Don't starve but ive not gotten around to doing it yet. Do you know of any good tutorials that you'd recommend?
https://www.lua.org/pil/contents.html
Then just google I guess...