Modulo:Videogioco: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
fix tabella |
fix ordine categorie e inserimento in categoria di errore se valorizzato args e args1 |
||
Riga 34:
new_s = mw.ustring.gsub(new_s, " ", " ")
return new_s
-- ========================================================================
-- Appende una tabella a un'altra tabella
-- ========================================================================
local function append_table(t1, t2)
t1[#t1+1] = el
end
Riga 45 ⟶ 54:
local function categorizza(args, base_name, table_name, lowercase, must_exist)
local categories = {}
local name_value = args[base_name]
if name_value then
if lowercase then name_value = mw.ustring.lower(name_value) end
local category = get_category(name_value, table_name)
if category then
categories[
elseif must_exist then
errors_msg[#errors_msg+1] = 'Valore non valido per ' .. base_name
end
while true do
name_value = args[base_name .. tostring(index)] if name_value then
if lowercase then name_value = mw.ustring.lower(name_value) end
local category = get_category(name_value, table_name)
if category then
categories[
elseif must_exist then
errors_msg[#errors_msg+1] = 'Valore non valido per ' .. base_name .. tostring(index)
break
end
▲ break
end
▲ index = index + 1
end
end
if args[base_name] and args[base_name .. "1"] then
errors_msg[#errors_msg+1] = 'Inserire solo uno di ' .. base_name .. ' e ' .. base_name .. tostring(index)
end
return categories
Riga 82 ⟶ 96:
if current_namespace ~= 0 and not frame.args.debug then return '' end
local categories = {}
append_table(categories
--if true then return mw.text.jsonEncode(categories) end
▲ categories.pubblicazione = categorizza(args, 'pubblicazione', 'aziende')
append_table(categories
if args.anno then
local anno = tonumber(args.anno)
if anno == nil then
errors_msg[#errors_msg+1] = 'anno di pubblicazione non valido'
elseif anno <= 1970 then
categories
else
categories
▲ end
▲ end
categories.tema = categorizza(args, 'tema', 'tema', true)▼
categories.genere = categorizza(args, 'genere', 'genere', true, true)▼
categories.piattaforme = categorizza(args, 'piattaforma', 'piattaforma', false, true)▼
categories.distribuzione = categorizza(args, 'distribuzionedigitale', 'distribuzione', false, true)▼
for cat_name,cat_list in pairs(categories) do▼
end
end
▲ for cat,_ in pairs(cat_dict) do
▲ append_table(categories
cat_list[#cat_list+1] = '[[Categoria:' .. cat .. ']]'▼
▲ append_table(categories
end
if #errors_msg>0 then
end
if #
return frame.args.debug and mw.text.nowiki(table.concat(
end
----------------------------------------------------------------------------------
|