Jump to content

Module:ChartColors and Module:ChartColors/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
Fix unintended global variable (and I wish people wouldn't stricten transitive dependencies to force this on me)
 
No edit summary
 
Line 1: Line 1:
require('strict')
local p = {}
local p = {}


local ARG = require "Module:Arguments"
local ARG = require "Module:Arguments"
local CFCM = require "Module:ComplForColorModules"
local CFCM = require "Module:ComplForColorModules/sandbox"
local TNTT = require "Module:TNTTools"
local TNTT = require "Module:TNTTools"
--local SD = require "Module:SimpleDebug"
local SD = require "Module:SimpleDebug"


local I18n = 'ChartColors'
local I18n = 'ChartColors'
Line 38: Line 37:
error (I18nStr ('ColorNameInvalid',ColorName))
error (I18nStr ('ColorNameInvalid',ColorName))
end
end
local MaxN = table.getn(Palet0)
MaxN = table.getn(Palet0)
if (N < 0) or (N > MaxN) then
if (N < 0) or (N > MaxN) then
error (I18nStr ('ColorNumInvalid',tostring(MaxN),tostring(N)))
error (I18nStr ('ColorNumInvalid',tostring(MaxN),tostring(N)))
else
else
local Palet = {}
Palet = {}
if IsInv then
if IsInv then
for i=MaxN, 1, -1 do
for i=MaxN, 1, -1 do
Line 66: Line 65:
end
end
else
else
local Count = 0
Count = 0
for i=StartN, MaxN, Step do
for i=StartN, MaxN, Step do
table.insert(SelColors, Palet[i])
table.insert(SelColors, Palet[i])
Line 107: Line 106:
end --ColorNameInvStartFromS
end --ColorNameInvStartFromS


local function ColorNameInv (args)
function ColorNameInv (args)
local S = args[1] or ''
local S = args[1] or ''
local ColorName, IsInv, ParamsA = CFCM.ColorNameInvFromS0 (S)
local ColorName, IsInv, ParamsA = CFCM.ColorNameInvFromS0 (S)
Line 120: Line 119:
});
});
local ColorName, IsInv, StartN = ColorNameInv (args)
local ColorName, IsInv, StartN = ColorNameInv (args)
local N = tonumber(args[2])
local N = tonum(args[2])
local WriteColor = args[3] or ""
local WriteColor = args[3] or ""
local ColorFound = {}
local ColorFound = {}
Line 135: Line 134:
removeBlanks = false
removeBlanks = false
})
})
local Nargs = require("Module:TableTools").length(args)
local ColorName, IsInv, StartN = ColorNameInv (args)
local ColorName, IsInv, StartN = ColorNameInv (args)
local N = tonumber(args[2])
local N = tonumber(args[2])
Line 142: Line 140:
local Labels = {}
local Labels = {}
local NLabels = 0
local NLabels = 0
local OutlineColor
local IsTemplate = true
local IsTemplate = true
ColorFound = p.GetColors (ColorName, IsInv, StartN, N, true)
ColorFound = p.GetColors (ColorName, IsInv, StartN, N, true)