Conan Exiles Wiki
No edit summary
No edit summary
(47 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
function p.Main( frame )
 
function p.Main( frame )
 
local inpSet = frame.args['set']
 
local inpSet = frame.args['set']
local inpType = "base"
+
local inpSource = frame.args['source']
if frame.args['type'] and frame.args['type'] ~= "" then
+
local inpImage = frame.args['image']
inpType = frame.args['type']
 
end
 
local inpExceptional = (inpType == "exceptional") or false
 
local inpFlawless = (inpType == "flawless") or false
 
local inpEpic = false
 
if frame.args['epic'] == "true" then
 
inpEpic = true
 
end
 
local inExclude = frame.args['exclude']
 
   
 
-- prepare query
 
-- prepare query
local where = '_pageName '
+
local where = 'armorset = "' .. inpSet .. '"'
 
 
-- epic
 
if not inpEpic then
 
where = where .. "NOT"
 
end
 
where = where .. ' LIKE "%(Epic)" AND '
 
 
-- exceptional
 
local where = where .. '_pageName '
 
if not inpExceptional then
 
where = where .. "NOT"
 
end
 
where = where .. ' LIKE "Exceptional %" AND '
 
 
-- flawless
 
local where = where .. '_pageName '
 
if not inpFlawless then
 
where = where .. "NOT"
 
end
 
where = where .. ' LIKE "Flawless %" AND '
 
 
-- set name (and exclude saddle, padding and lining)
 
where = where .. '_pageName LIKE "%' .. inpSet .. '%" AND _pageName NOT LIKE "%Saddle%" AND _pageName NOT LIKE "%Padding%" AND _pageName NOT LIKE "%Lining%" '
 
 
-- exclude
 
if inExclude ~= "" then
 
where = where .. '_pageName NOT LIEK "%' .. inExclude .. '%" '
 
end
 
 
 
tables = 'Item'
 
tables = 'Item'
fields = 'id, name, _pageName, bonus, heatres, coldres, dlcPackage'
+
fields = 'id, name, _pageName, bonus, heatres, coldres, armor, dlcPackage, equipslot'
 
local args = {
 
local args = {
where = '_pageName=uniqueName AND type="Armor" AND id IS NOT NULL AND ' .. where,
+
where = 'type="Armor" AND ' .. where,
  +
orderBy = 'equipslot',
 
groupBy = 'id,_pageName',
 
groupBy = 'id,_pageName',
 
limit = 10
 
limit = 10
Line 56: Line 20:
 
 
 
-- itemlist
 
-- itemlist
local itemList = "" -- inpSet .. " / " .. inpExceptional .. " / " .. where
+
local itemList = ""
local foundHeatres, foundColdres = false
+
local foundHeatres, foundColdres, foundArmor = false
 
local dlcPackage
 
local dlcPackage
local attr = {["Accuracy"] = 0, ["Agility"] = 0, ["Grit"] = 0, ["Encumbrance"] = 0, ["Strength"] = 0, ["Vitality"] = 0}
+
local attr = {["Accuracy"] = 0, ["Agility"] = 0, ["Grit"] = 0, ["Encumbrance"] = 0, ["Strength"] = 0, ["Survival"] = 0, ["Vitality"] = 0}
  +
local tempResis = {["HeatResi"] = 0, ["ColdResi"] = 0}
 
local tempArmor = 0
   
 
local results = cargo.query( tables, fields, args )
 
local results = cargo.query( tables, fields, args )
  +
local lastEquipslot = -1
 
for r = 1, #results do
 
for r = 1, #results do
 
local result = results[r]
 
local result = results[r]
Line 71: Line 38:
 
if tonumber(result["heatres"]) or 0 > 0 then
 
if tonumber(result["heatres"]) or 0 > 0 then
 
foundHeatres = true
 
foundHeatres = true
  +
tempResis["HeatResi"] = tempResis["HeatResi"] + tonumber(result["heatres"])
 
end
 
end
 
if tonumber(result["coldres"]) or 0 > 0 then
 
if tonumber(result["coldres"]) or 0 > 0 then
 
foundColdres = true
 
foundColdres = true
  +
tempResis["ColdResi"] = tempResis["ColdResi"] + tonumber(result["coldres"])
 
end
  +
  +
-- armor
  +
if result["armor"] ~= "" then
 
foundArmor = true
  +
tempArmor = tempArmor + tonumber(result["armor"])
 
end
 
end
 
 
 
-- bonus
 
-- bonus
 
if result["bonus"] ~= "" then
 
if result["bonus"] ~= "" then
  +
-- only add bonus of it is a differnet equipslot than the last one
local value, key = string.match(result["bonus"],'(%d+)%s*(%a+)')
 
if attr[key] then
+
if result["equipslot"] ~= lastEquipslot then
value = value + attr[key]
+
lastEquipslot = result["equipslot"]
  +
for x in string.gmatch(result["bonus"], "([^,]+)") do
attr[key] = value
 
 
local value, key = string.match(x,'(%d+)%s*(%a+)')
end
 
  +
if attr[key] then
  +
value = value + attr[key]
  +
attr[key] = value
  +
end
 
end
 
end
 
end
 
end
 
 
Line 98: Line 79:
 
local subHeadline = ""
 
local subHeadline = ""
 
 
-- heat/cold res
+
-- armor
if foundColdres and foundHeatres then
+
if foundArmor then
subHeadline = subHeadline .. "[[File:T_tooltip_warmIcon.png|frameless|32px|link=]]" .. "/" .. "[[File:T_tooltip_coldIcon.png|frameless|32px|link=]]" .. " Heat and Cold resistance"
+
subHeadline = subHeadline .. tempArmor .. " base armor"
elseif foundHeatres then
 
subHeadline = subHeadline .. "[[File:T_tooltip_warmIcon.png|frameless|32px|link=]]" .. " Heat resistance"
 
elseif foundColdres then
 
subHeadline = subHeadline .. "[[File:T_tooltip_coldIcon.png|frameless|32px|link=]]" .. " Cold resistance"
 
 
end
 
end
  +
 
-- bonus
 
-- bonus
 
local bonus = ""
 
local bonus = ""
Line 117: Line 95:
 
end
 
end
 
if bonus ~= "" then
 
if bonus ~= "" then
subHeadline = subHeadline .. ", " .. bonus
+
subHeadline = subHeadline .. ", " .. bonus
 
end
 
end
 
 
-- dlc
 
-- dlc
 
if dlcPackage and dlcPackage ~= "" then
 
if dlcPackage and dlcPackage ~= "" then
 
subHeadline = subHeadline .. ", [[Downloadable Content|DLC]] [[" .. dlcPackage .. "]]"
 
subHeadline = subHeadline .. ", [[Downloadable Content|DLC]] [[" .. dlcPackage .. "]]"
 
end
 
end
  +
  +
-- heat/cold res
 
if foundHeatres then
 
subHeadline = subHeadline .. "<br>[[File:T_tooltip_warmIcon.png|frameless|32px|link=]]"
  +
  +
local bars = math.floor(tempResis["HeatResi"]/4)
  +
if tempResis["HeatResi"]%4 > 0 then
  +
bars = bars+1
  +
end
  +
if bars > 10 then
  +
bars = 10
  +
end
  +
  +
for i=1, bars do
  +
subHeadline = subHeadline .. "[[File:T_tooltip_warmSlot.png|frameless|link=]]"
  +
end
  +
for i=bars+1, 10 do
  +
subHeadline = subHeadline .. "[[File:T_tooltip_emptySlot.png|frameless|link=]]"
  +
end
  +
  +
subHeadline = subHeadline .. " (" .. tempResis["HeatResi"] .. ")"
 
end
  +
 
if foundColdres then
  +
if foundHeatres then
  +
subHeadline = subHeadline .. ", "
  +
else
  +
subHeadline = subHeadline .. "<br>"
  +
end
  +
 
subHeadline = subHeadline .. " [[File:T_tooltip_coldIcon.png|frameless|32px|link=]]"
  +
  +
local bars = math.floor(tempResis["ColdResi"]/4)
  +
if tempResis["ColdResi"]%4 > 0 then
  +
bars = bars+1
  +
end
  +
if bars > 10 then
  +
bars = 10
  +
end
  +
  +
for i=1, bars do
  +
subHeadline = subHeadline .. "[[File:T_tooltip_coldSlot.png|frameless|link=]]"
  +
end
  +
  +
for i=bars+1, 10 do
  +
subHeadline = subHeadline .. "[[File:T_tooltip_emptySlot.png|frameless|link=]]"
  +
end
  +
  +
subHeadline = subHeadline .. " (" .. tempResis["ColdResi"] .. ")"
 
end
  +
  +
if not foundHeatres and not foundColdres then
  +
subHeadline = subHeadline .. "<br>No resistances"
 
end
  +
 
subHeadline = subHeadline .. "\n"
 
subHeadline = subHeadline .. "\n"
 
 
  +
-- source
return headline .. subHeadline .. itemList
 
  +
local source = ""
  +
  +
if inpSource and inpSource ~= "" then
  +
source = "The prerequisite to craft this is:\n"
  +
source = source .. "* [[" .. inpSource .. "]]\n"
  +
source = source .. "&nbsp;"
 
end
  +
  +
-- image
  +
if inpImage and inpImage ~= "" then
  +
-- wrap itemList into a tabel and add the image to the second cell
  +
local itemListWrapped = '{|width="750px"\n'
  +
itemListWrapped = itemListWrapped .. '|width="500px"|\n' .. itemList .. '\n'
  +
itemListWrapped = itemListWrapped .. '| style="vertical-align:top;" | ' .. '[[File:' .. inpImage .. '|250px|' .. inpSet .. ']]' .. '\n'
  +
itemListWrapped = itemListWrapped .. '|}'
  +
  +
itemList = itemListWrapped
  +
end
  +
 
return headline .. subHeadline .. '<div class="mw-collapsible-content">\n' .. itemList .. source .. '</div>\n'
 
end
 
end
 
return p
 
return p

Revision as of 18:14, 22 May 2022

Documentation for this module may be created at Module:ArmorSet/doc

local p = {}
local cargo = mw.ext.cargo

function p.Main( frame )
	local inpSet = frame.args['set']
	local inpSource = frame.args['source']
	local inpImage = frame.args['image']

	-- prepare query
	local where = 'armorset = "' .. inpSet .. '"'
	
	tables = 'Item'
    fields = 'id, name, _pageName, bonus, heatres, coldres, armor, dlcPackage, equipslot'
    local args = {
        where = 'type="Armor" AND ' .. where,
        orderBy = 'equipslot',
        groupBy = 'id,_pageName',
        limit = 10
    }
    
    -- itemlist
	local itemList = ""
	local foundHeatres, foundColdres, foundArmor = false
	local dlcPackage
	local attr = {["Accuracy"] = 0, ["Agility"] = 0, ["Grit"] = 0, ["Encumbrance"] = 0, ["Strength"] = 0, ["Survival"] = 0, ["Vitality"] = 0}
	local tempResis = {["HeatResi"] = 0, ["ColdResi"] = 0}
	local tempArmor = 0

    local results = cargo.query( tables, fields, args )
    local lastEquipslot = -1
    for r = 1, #results do
        local result = results[r]
        
        -- item list
        itemList = itemList .. "* " .. frame:callParserFunction('#invoke:ItemLink', 'Main', result["_pageName"]) .. "\n" 
        
        -- heat/cold res
        if tonumber(result["heatres"]) or 0 > 0 then
        	foundHeatres = true	
        	tempResis["HeatResi"] = tempResis["HeatResi"] + tonumber(result["heatres"])
        end
        if tonumber(result["coldres"]) or 0 > 0 then
        	foundColdres = true	
        	tempResis["ColdResi"] = tempResis["ColdResi"] + tonumber(result["coldres"])
        end
        
        -- armor
        if result["armor"] ~= "" then
        	foundArmor = true
        	tempArmor = tempArmor + tonumber(result["armor"])
        end
        
        -- bonus
        if result["bonus"] ~= "" then
        	-- only add bonus of it is a differnet equipslot than the last one
        	if result["equipslot"] ~= lastEquipslot then
        		lastEquipslot = result["equipslot"]
	        	for x in string.gmatch(result["bonus"], "([^,]+)") do
		        	local value, key = string.match(x,'(%d+)%s*(%a+)')
		        	if attr[key] then
		        		value = value + attr[key]
		        		attr[key] = value
		        	end
				end
			end
        end
        	
        -- dlc
        if not dlcPackage then
        	dlcPackage = result["dlcPackage"]
        end
    end
	
	-- prepare result
	-- headline
	local headline = '<div style="font-size: 14px; font-weight:bold; color:#a38369">' .. inpSet .. '</div>\n'
    
    -- sub-headline
    local subHeadline = ""
    
    -- armor
    if foundArmor then
    	subHeadline = subHeadline .. tempArmor .. " base armor"	
    end
    
    -- bonus
    local bonus = ""
    for k, v in pairs(attr) do
    	if v > 0 then
    		if bonus ~= "" then
    			bonus = bonus .. " "
    		end
    		bonus = bonus .. "+" .. v .. " " .. k
    	end
	end
	if bonus ~= "" then
			subHeadline = subHeadline .. ", " .. bonus
	end
	
    -- dlc
    if dlcPackage and dlcPackage ~= "" then
    	subHeadline = subHeadline .. ", [[Downloadable Content|DLC]] [[" .. dlcPackage .. "]]"
    end
    
    -- heat/cold res
    if foundHeatres then
    	subHeadline = subHeadline .. "<br>[[File:T_tooltip_warmIcon.png|frameless|32px|link=]]" 
    	
    	local bars = math.floor(tempResis["HeatResi"]/4)
    	if tempResis["HeatResi"]%4 > 0 then
    		bars = bars+1
    	end
    	if bars > 10 then
    		bars = 10
    	end
    	
    	for i=1, bars do 
    		subHeadline = subHeadline .. "[[File:T_tooltip_warmSlot.png|frameless|link=]]"
    	end
    	for i=bars+1, 10 do
    		subHeadline = subHeadline .. "[[File:T_tooltip_emptySlot.png|frameless|link=]]"
    	end
    	
    	subHeadline = subHeadline .. " (" .. tempResis["HeatResi"] .. ")"
    end

    if foundColdres then
    	if foundHeatres then
    		subHeadline = subHeadline .. ", "
    	else
    		subHeadline = subHeadline .. "<br>"
    	end
    	
    	subHeadline = subHeadline .. " [[File:T_tooltip_coldIcon.png|frameless|32px|link=]]"
    	
    	local bars = math.floor(tempResis["ColdResi"]/4)
    	if tempResis["ColdResi"]%4 > 0 then
    		bars = bars+1
    	end
    	if bars > 10 then
    		bars = 10
    	end
    	
    	for i=1, bars do
    		subHeadline = subHeadline .. "[[File:T_tooltip_coldSlot.png|frameless|link=]]"
    	end
    	
    	for i=bars+1, 10 do
    		subHeadline = subHeadline .. "[[File:T_tooltip_emptySlot.png|frameless|link=]]"
    	end
    	
    	subHeadline = subHeadline .. " (" .. tempResis["ColdResi"] .. ")"
    end
    
    if not foundHeatres and not foundColdres then
    	subHeadline = subHeadline .. "<br>No resistances"
    end
    
    subHeadline = subHeadline .. "\n"
    
    -- source
    local source = ""
    
    if inpSource and inpSource ~= "" then
    	source = "The prerequisite to craft this is:\n"
    	source = source .. "* [[" .. inpSource .. "]]\n"
    	source = source .. "&nbsp;"
    end
    
    -- image
    if inpImage and inpImage ~= "" then
    	-- wrap itemList into a tabel and add the image to the second cell
    	local itemListWrapped = '{|width="750px"\n'
    	itemListWrapped = itemListWrapped .. '|width="500px"|\n' .. itemList .. '\n'
    	itemListWrapped = itemListWrapped .. '| style="vertical-align:top;" | ' .. '[[File:' .. inpImage .. '|250px|' .. inpSet .. ']]' .. '\n'
    	itemListWrapped = itemListWrapped .. '|}'
    	
    	itemList = itemListWrapped
    end
    
    return headline .. subHeadline .. '<div class="mw-collapsible-content">\n' .. itemList .. source .. '</div>\n'
end
return p