I see now why you're using this method, I apologize if I seemed rude. The method I was going to suggest won't work in this case.
However, I do have another suggestion. I have gone ahead and downloaded the .RMSKIN you provided and stripped it apart. I realized that a tool that I made for a completely separate purpose could be used here. I have attached the new .RMSKIN to this reply.
The gist of the changes I made are to no longer rely on !WriteKeyValue bangs (except for the creation of the Underliner_Width variable). Instead, my script reads in a template file and parses it, replacing every instance of a specific marker (
^1^ in this case) with the first disk letter. It then goes and does the same with all of the disk letters contained in the
AllDisks variable. Once finished, it writes the result into the output file and saves it.
This has numerous advantages over your !WriteKeyValue method: first, you can edit the template just like a normal skin, significantly decreasing the amount of work that goes into changing or adding an option; second, it is much more reliable and doesn't require you to escape the variables.
I hope I explained that clearly. If you need any help on how the script works (I jury-rigged it to work for this specific usecase, so it is kinda messy and has a lot of excess code), feel free to shoot me a reply.
Another important change is that rather than using the script update function to update the contents of AllDisks, I simply pass it as an option on the script measure, and only have the LUA retrieve it when it actually needs it.
Here's the code for the script:
Code: Select all
debug = false
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
revAlphabet = 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
identifierString = '%^(#)%^'
function Initialize()
cTable = newT()
bTable = newT()
keyIndex = 0
tableLength = 0
end
function Update() end
function Split()
local lTable = {}
SELF:GetOption('AllDisks'):gsub(".", function(c)
table.insert(lTable, c)
SKIN:Bang(string.format('!WriteKeyValue Variables "Underliner_Width_%s" "0" "#@#Variables.inc"',c))
end)
LogHelper(SELF:GetOption('AllDisks'))
AddTable{ type = 'custom', customTable = lTable }
Concat()
end
function Concat()
local rTable = {}
local lines = {}
for line in io.lines(SELF:GetOption('templateFilePath')) do
table.insert(rTable, line)
end
for i = 1, tableLength do
for l,line in pairs(rTable) do
for k,v in cTable:opairs() do
if v[i] ~= nil then line = line:gsub(k, v[i]) end
end
table.insert(lines, line)
end
end
outputFile = io.open(SELF:GetOption('outputFilePath'), 'w')
outputFile:write(table.concat(lines, '\n'))
outputFile:close()
end
function AddTable(args)
keyIndex = keyIndex + 1
cTable[identifierString:gsub('%(#%)', keyIndex)] = BuildTable(args)
end
function BuildTable(args)
local type = args.type
local start = args.start
local finish = args.finish
local customTable = args.customTable
local lTable = {}
if type == 'alphabetical' then
alphabet:gsub(".", function(c)
table.insert(lTable, c)
end)
elseif type == 'revAlphabetical' then
revAlphabet:gsub(".", function(c)
table.insert(lTable, c)
end)
elseif type == 'numerical' then
for i = start,finish do
table.insert(lTable, i)
end
elseif type == 'revNumerical' then
for i = start,finish,-1 do
table.insert(lTable, i)
end
elseif type == 'custom' then
lTable = customTable
end
if tablelength(lTable) > tableLength then tableLength = tablelength(lTable) end
return lTable
end
-- function to make logging messages less cluttered
function LogHelper(message, type)
if type == nil then type = 'Debug' end
if debug == true then
SKIN:Bang("!Log", message, type)
elseif type ~= 'Debug' then
SKIN:Bang("!Log", message, type)
end
end
-- simple ordered table (http://lua-users.org/wiki/OrderedTableSimple)
function newT( t )
local mt = {}
-- set methods
mt.__index = {
-- set key order table inside __index for faster lookup
_korder = {},
-- traversal of hidden values
hidden = function() return pairs( mt.__index ) end,
-- traversal of table ordered: returning index, key
ipairs = function( self ) return ipairs( self._korder ) end,
-- traversal of table
pairs = function( self ) return pairs( self ) end,
-- traversal of table ordered: returning key,value
opairs = function( self )
local i = 0
local function iter( self )
i = i + 1
local k = self._korder[i]
if k then
return k,self[k]
end
end
return iter,self
end,
-- to be able to delete entries we must write a delete function
del = function( self,key )
if self[key] then
self[key] = nil
for i,k in ipairs( self._korder ) do
if k == key then
table.remove( self._korder, i )
return
end
end
end
end,
}
-- set new index handling
mt.__newindex = function( self,k,v )
if k ~= "del" and v then
rawset( self,k,v )
table.insert( self._korder, k )
end
end
return setmetatable( t or {},mt )
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
You do not have the required permissions to view the files attached to this post.