Content deleted Content added
more bug fixes for the config formatting function - we can't add values to the same table at the same time we are iterating over it, so build a new config table instead |
some minor rearrangements |
||
Line 20:
and num > 0
and num < math.huge
end▼
local function substituteParams(msg, ...)
return mw.message.newRawMessage(msg, ...):plain()
end
Line 40 ⟶ 44:
-- code, result, link, paramNum, actionCfg
local obj = setmetatable({}, Action)
obj.id = data.id
obj.name = data.name
obj.oldid = data.oldid
obj.paramNum = data.paramNum
return obj
end
Line 138 ⟶ 148:
obj.cfg = substituteAliases(cfg or require(CONFIG_PAGE))
do
return obj▼
▲end
▲ -- Filter the arguments for actions.
▲ local actionParams = {}
if type(k) == 'string' then▼
▲ local pattern = '^' .. self.cfg.actionParamPrefix .. '([1-9][0-9]*)(.-)$'
local num, suffix = key:match(pattern)
▲ local suffixes = self.cfg.actionParamSuffixes
▲ for k, v in pairs(args) do
▲ if type(k) == 'string' then
local
t.num =
▲ t[suffixes[suffix]] = v
▲ t.num = num
end
table.insert(actionParamsSorted, t)▼
return t1.num < t2.num▼
end)
-- Create the action objects.
end
end
▲ return obj
▲ -- Sort the action parameters.
▲ local actionParamsSorted = {}
▲ for num, t in pairs(actionParams) do
▲ table.insert(actionParamsSorted, t)
▲ end
▲ table.sort(actionParamsSorted, function (t1, t2)
▲ return t1.num < t2.num
▲ end)
▲ -- Create the action objects.
▲ for _, t in ipairs(actionParamsSorted) do
▲ table.insert(self.actions, Action.new(t))
▲ end
end
|