Module:MaterialInfobox: Difference between revisions

Content deleted Content added
Everything seems to be working now
Corrected Rare and Very Rare icons
 
(9 intermediate revisions by 3 users not shown)
Line 23:
if not HF.isempty(field.Grade) then
if field.Grade == 'Rare' or field.Grade == 'rare' then
output = '[[File:placeholderRare_material.pngsvg|35px|link=]] ' .. output
elseif field.Grade == 'Very common' or field.Grade == 'Very Common' or field.Grade == 'very common' then
output = '[[File:placeholderVery common material.pngsvg|35px|link=]] ' .. output
elseif field.Grade == 'Very rare' or field.Grade == 'Very Rare' or field.Grade == 'very rare' then
output = '[[File:Very_Rare_material.svg|35px|link=]] ' .. output
elseif field.Grade == 'Common' or field.Grade == 'common' then
output = '[[File:placeholderCommon material.pngsvg|35px|link=]] ' .. output
elseif field.Grade == 'Standard' or field.Grade == 'standard' then
output = '[[File:Standard_material.svg|35px|link=]] ' .. output
else
output = output
Line 35 ⟶ 39:
end
 
function Infobox.SplitNewlineTableSplitRows( field, vars )▼
--[[ Everything after this is stuff you may or may not want to keep --]]
function Infobox.SplitTest( field, vars, value )
return "abc" .. value .. "cba"
end
 
function SplitRunFunction(func_name, field, vars, value)
if type( func_name ) == "string" then
if not HF.isempty( func_name ) then
if type( Infobox[func_name] ) == "function" then
return Infobox[func_name]( field, vars, value ) --[[ I tried a hack where I modified field.Value to little success, so I resorted to calling it with different arguments --]]
end▼
end
end
return value
end
 
function Infobox.ExampleSplitLabelMethod( field, vars )
return {
SplitRunFunction( field.LabelLeftMethod, field, vars, field.LabelLeft ),
SplitRunFunction( field.LabelRightMethod, field, vars, field.LabelRight )
}
end
function Infobox.ExampleSplitValueMethod( field, vars )
return {
SplitRunFunction( field.ValueLeftMethod, field, vars, field.ValueLeft ),
SplitRunFunction( field.ValueRightMethod, field, vars, field.ValueRight )
}
end
 
--[[ Carbon copy of Infobox.Newline lazily modified to for Split fields --]]
function SplitNewlineHelper( value )
local output = ''
if not HF.isempty(valuefield.Value) then
local ships = HF.explode(';', valuefield.Value)
table.sort(ships)
for i, ship in ipairs(ships) do
output = output ..'<tr HF.trim(ship)class="eInfobox-infobox-custom .. 'custom-listitem"><brtd /colspan="2">' ..
table.concat(ships, '</td></tr><tr class="eInfobox-infobox-custom custom-listitem"><td colspan="2">') ..
end
▲ end '</td></tr>'
ifreturn string.sub(output, -6) == '<br />' then
output = string.sub( output, 1, -7 )
end
end
 
return output
end
 
▲function Infobox.SplitNewline( field, vars )
return {
SplitNewlineHelper( field.ValueLeft ),
SplitNewlineHelper( field.ValueRight )
}
end