You have a couple of errors, but it will change the value of the Drive option on the measure.
If I change your .lua to:
Code: Select all
function Initialize ()
-- The current drives connected to the computer.
-- 65 ~ 92
Drives = {}
DriveChecker = SKIN:GetMeasure("DriveType")
for i = 65, 90 do
CurrentDrive = string.char(i) .. ':'
SKIN:Bang('!SetOption', 'DriveType', 'Drive', CurrentDrive)
end
end
function Update ()
end
Then the Drive option will be set to "Z:" and the measure returns "Removed". Since I don't have any Z: drive.
Note I changed "92" to "90", and you had a formatting issue with your SKIN:Bang command. Once I fix those it works fine.
Which it not to say it does anything useful mind you. As I said, it will ALWAYS be set to "Z:" and the loop is entirely pointless.
Your "print" statement" in the Lua is also pointless, as the initial value of the measure's Drive option is not set, or "". That is all that any GetOption will see in that loop. Remember the entire Initialize() function will be executed in full during the initial skin Update cycle. The !SetOption to set the Drive option on the measure will not be seen by the skin until the Lua is done, and the control is returned back to the skin.
I hope I'm being clear. I hate to see you go down a rabbit hole that won't get you anywhere. The sequence of events for this skin when it is loaded or refreshed will be:
1) Create all measures and meters.
2) Start the first Update cycle.
3) Get the value of the [DriveType] measure. That will be whatever the type of your "C:" drive is, as that is the default when there is no Drive option defined.
4) Execute the Lua script. The script will do whatever is defined in it, but NOTHING the script communicates to the skin will be seen until the Lua is done.
5) When control is returned from the Lua script, take any actions in bangs in the Lua and set the value of the script measure to any "return" value from the Lua's Update() function. This will set the Drive option of the [DriveType] measure to "Z:".
6) Update the single meter you have defined. It has nothing to display of course, I expect it is just there as a place-holder.
7) Draw the skin.
8) Go to 2).