Module:Crafts/ingredient

local metals = { ['Copper/Tin'] = 1, ['Silver/Tungsten'] = 1, ['Gold/Platinum'] = 1, ['Iron/Lead'] = 1, ['Demonite/Crimtane'] = 1, ['Cobalt/Palladium'] = 1, ['Mythril/Orichalcum'] = 1, ['Adamantite/Titanium'] = 1, ['Tin/Copper'] = 2, ['Tungsten/Silver'] = 2, ['Platinum/Gold'] = 2, ['Lead/Iron'] = 2, ['Palladium/Cobalt'] = 2, ['Orichalcum/Mythril'] = 2, ['Titanium/Adamantite'] = 2, }

local function split(name) local item1a, item1b, item2a, item2b = name:match("^(%S+)%s*(.-)/(%S+)%s*(.-)$") if item1a then local x = metals[item1a..'/'..item2a] if tostring(item1b) == '' and x then item1b = item2b end if x == 2 then return item2a..' '..item2b, item1a..' '..item1b else return item1a..' '..item1b, item2a..' '..item2b end else return name end end

-- main return object return { go = function(frame) local _input = mw.text.trim(frame.args[1]) local _basepage = mw.text.trim(frame.args[2])

local icons

local result = '' for name, amount in _input:gmatch("(.-)¦(.-)¶") do		local li = '' item1, item2 = split(name) if item2 then li = li .. frame:expandTemplate{ title = 'item', args = {item1} } li = li .. " or " li = li .. frame:expandTemplate{ title = 'item', args = {item2} } else li = li .. frame:expandTemplate{ title = 'item', args = {name} } end result = result .. mw.text.tag('li', nil, li .. amount) end return mw.text.tag('ul', nil, result)

end }