Conan Exiles Wiki
No edit summary
No edit summary
(15 intermediate revisions by the same user not shown)
Line 11: Line 11:
 
 
 
tables = 'Item'
 
tables = 'Item'
fields = 'id, name, _pageName, bonus, heatres, coldres, dlcPackage'
+
fields = 'id, name, _pageName, bonus, heatres, coldres, dlcPackage, equipslot'
 
local args = {
 
local args = {
 
where = 'type="Armor" AND ' .. where,
 
where = 'type="Armor" AND ' .. where,
Line 27: Line 27:
   
 
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 45: Line 46:
 
-- bonus
 
-- bonus
 
if result["bonus"] ~= "" then
 
if result["bonus"] ~= "" then
  +
-- only add bonus of it is a differnet equipslot than the last one
for x in string.gmatch(result["bonus"], "([^,]+)") do
 
  +
if result["equipslot"] ~= lastEquipslot then
local value, key = string.match(x,'(%d+)%s*(%a+)')
 
if attr[key] then
+
lastEquipslot = result["equipslot"]
value = value + attr[key]
+
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
 
end
Line 77: Line 82:
 
end
 
end
 
subHeadline = subHeadline .. "[[File:T_tooltip_coldIcon.png|frameless|32px|link=]] " .. tempResis["ColdResi"] .. " Cold resistance"
 
subHeadline = subHeadline .. "[[File:T_tooltip_coldIcon.png|frameless|32px|link=]] " .. tempResis["ColdResi"] .. " Cold resistance"
  +
end
  +
  +
if not foundHeatres and not foundColdres then
  +
subHeadline = subHeadline .. "No resistances"
 
end
 
end
 
 
Line 90: Line 99:
 
end
 
end
 
if bonus ~= "" then
 
if bonus ~= "" then
if foundColdres or foundHeatres then
+
--if foundColdres or foundHeatres then
 
subHeadline = subHeadline .. ", "
 
subHeadline = subHeadline .. ", "
end
+
--end
 
subHeadline = subHeadline .. bonus
 
subHeadline = subHeadline .. bonus
 
end
 
end
Line 107: Line 116:
 
if inpSource and inpSource ~= "" then
 
if inpSource and inpSource ~= "" then
 
source = "The prerequisite to craft this is:\n"
 
source = "The prerequisite to craft this is:\n"
source = source .. "* [[" .. inpSource .. "]]"
+
source = source .. "* [[" .. inpSource .. "]]\n"
  +
source = source .. " "
 
end
 
end
 
 
Line 113: Line 123:
 
if inpImage and inpImage ~= "" then
 
if inpImage and inpImage ~= "" then
 
-- wrap itemList into a tabel and add the image to the second cell
 
-- wrap itemList into a tabel and add the image to the second cell
local itemListWrapped = '{|width="760px"\n|width="500px""'
+
local itemListWrapped = '{|width="750px"\n'
itemListWrapped = itemListWrapped .. '| ' .. itemList .. '\n'
+
itemListWrapped = itemListWrapped .. '|width="500px"|\n' .. itemList .. '\n'
itemListWrapped = itemListWrapped .. '|style="vertical-align:top;"|[[File:{{{inpImage}}}{{!}}250px{{!}}{{{Set}}}]]\n'
+
itemListWrapped = itemListWrapped .. '| style="vertical-align:top;" | ' .. '[[File:' .. inpImage .. '|250px|' .. inpSet .. ']]' .. '\n'
 
itemListWrapped = itemListWrapped .. '|}'
 
itemListWrapped = itemListWrapped .. '|}'
 
 
Line 121: Line 131:
 
end
 
end
 
 
return headline .. subHeadline .. '<div class="mw-collapsible-content">\n' .. itemList .. source .. '</div>'
+
return headline .. subHeadline .. '<div class="mw-collapsible-content">\n' .. itemList .. source .. '</div>\n'
 
end
 
end
 
return p
 
return p

Revision as of 12:21, 3 June 2021

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, dlcPackage, equipslot'
    local args = {
        where = 'type="Armor" AND ' .. where,
        orderBy = 'equipslot',
        groupBy = 'id,_pageName',
        limit = 10
    }
    
    -- itemlist
	local itemList = ""
	local foundHeatres, foundColdres = 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 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
        
        -- 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 = ""
    
    -- heat/cold res
    if foundHeatres then
    	subHeadline = subHeadline .. "[[File:T_tooltip_warmIcon.png|frameless|32px|link=]] " .. tempResis["HeatResi"] .. " Heat resistance"
    end

    if foundColdres then
    	if foundHeatres then
    		subHeadline = subHeadline .. ", "
    	end
    	subHeadline = subHeadline .. "[[File:T_tooltip_coldIcon.png|frameless|32px|link=]] " .. tempResis["ColdResi"] .. " Cold resistance"
    end
    
    if not foundHeatres and not foundColdres then
    	subHeadline = subHeadline .. "No resistances"
    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
		--if foundColdres or foundHeatres then
			subHeadline = subHeadline .. ", "
		--end
		subHeadline = subHeadline .. bonus	
	end
	
    -- dlc
    if dlcPackage and dlcPackage ~= "" then
    	subHeadline = subHeadline .. ", [[Downloadable Content|DLC]] [[" .. dlcPackage .. "]]"
    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