Änderungen

Wechseln zu: Navigation, Suche

Modul:Recipes

7.386 Bytes hinzugefügt, vor 2 Jahren
Für {{recipes/extract}} aktualisiert. // Updated for {{recipes/extract}}.
end
return station
end
 
local normalizeVersion = function(_version)
local _version = trim(args['version'] or ''):lower()
local version = ''
if _version:find('desktop', 1, true) then
version = version .. ' desktop'
end
if _version:find('console', 1, true) then
version = version .. ' console'
elseif _version:find('konsole', 1, true) then
version = version .. ' console'
end
if _version:find('old-gen', 1, true) then
version = version .. ' old-gen'
end
if _version:find('japan', 1, true) then
version = version .. ' japan'
end
if _version:find('mobile', 1, true) then
version = version .. ' mobile'
elseif _version:find('mobil', 1, true) then
version = version .. ' mobile'
end
if _version:find('3ds', 1, true) then
version = version .. ' 3ds'
end
if version == ' desktop console old-gen mobile 3ds' then
version = ''
elseif version == ' desktop konsole old-gen mobile 3ds' then
version = ''
elseif version == ' desktop console old-gen mobil 3ds' then
version = ''
elseif version == ' desktop konsole old-gen mobil 3ds' then
version = ''
end
return trim(version)
end
 
end
constraints['ingredient'] = str
end
--versions
local _version = normalizeVersion(args['version'] or args['versions'] or '')
if _version ~= '' then
constraints['version'] = 'version = '..enclose(_version)
end
 
end
where = where .. '(' .. constraints['ingredient'] .. ')'
end
if constraints['version'] then
if where ~= '' then
where = where .. ' AND '
end
where = where .. '(' .. constraints['version'] .. ')'
end
return where
end
 
local resultCell = function(row, showResultId, needLink, noVersion)
local result, resultid, resultimage, resulttext, amount, version = row['result'], row['resultid'], row['resultimage'], row['resulttext'], row['amount'], row['version']
local str = ''
str = str .. ' <span class="note-text">('..amount..')</span>'
end
if versionnot ~= ''noVersion then
if version ~= '' then
str = str .. ' (' ..currentFrame:expandTemplate{ title = 'version icons', args = {version} }..')'
end
end
return str
else
return station
end
end
-- for extract.
local compactStation = function(station)
if station == 'By Hand' then
return ''
elseif station == 'Furnace' or station == 'Work Bench' or station == 'Sawmill' or station == "Tinkerer's Workshop" or station == 'Dye Vat'
or station == 'Loom' or station == 'Keg' or station == 'Hellforge' or station == 'Bookcase' or station == 'Imbuing Station' or station == 'Lava'
or station == 'Honey' or station == 'Glass Kiln' or station == 'Flesh Cloning Vat' or station == 'Autohammer' or station == 'Crystal Ball'
or station == 'Ice Machine' or station == 'Meat Grinder' or station == 'Living Loom' or station == 'Heavy Work Bench' or station == 'Sky Mill'
or station == 'Solidifier' or station == 'Honey Dispenser' or station == 'Bone Welder' or station == 'Blend-O-Matic' or station == 'Steampunk Boiler'
or station == 'Ancient Manipulator' or station == 'Lihzahrd Furnace' or station == 'Living Wood' then
return ' @&thinsp;' .. itemLink(station, {mode = 'image'})
elseif station == 'Iron Anvil' then
return ' @&thinsp;' .. itemLink('Iron Anvil', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Lead Anvil', {mode = 'image'})
elseif station == 'Adamantite Forge' then
return ' @&thinsp;' .. itemLink('Adamantite Forge', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Titanium Forge', {mode = 'image'})
elseif station == 'Mythril Anvil' then
return ' @&thinsp;' .. itemLink('Mythril Anvil', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Orichalcum Anvil', {mode = 'image'})
elseif station == 'Demon Altar' then
return ' @&thinsp;' .. itemLink('Demon Altar', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Crimson Altar', {mode = 'image'})
elseif station == 'Cooking Pot' then
return ' @&thinsp;' .. itemLink('Cooking Pot', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Cauldron', {mode = 'image'})
elseif station == 'Placed Bottle' then
return ' @&thinsp;' .. itemLink('Placed Bottle', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Alchemy Table', {mode = 'image'})
elseif station == 'Water' then
return ' @&thinsp;' .. itemLink('Water', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Sink', {mode = 'image'})
elseif station == 'Table and Chair' then
return ' @&thinsp;' .. itemLink('Table', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;" .. itemLink('Chair', {mode = 'image'})
elseif station == 'Work Bench and Chair' then
return ' @&thinsp;' .. itemLink('Work Bench', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;" .. itemLink('Chair', {mode = 'image'})
elseif station == 'Crystal Ball and Lava' then
return ' @&thinsp;' .. itemLink('Crystal Ball', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;" .. itemLink('Lava', {mode = 'image'})
elseif station == 'Crystal Ball and Honey' then
return ' @&thinsp;' .. itemLink('Crystal Ball', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;" .. itemLink('Honey', {mode = 'image'})
elseif station == 'Crystal Ball and Water' then
return ' @&thinsp;' .. itemLink('Crystal Ball', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;".. '(&thinsp;' .. itemLink('Water', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Sink', {mode = 'image'}) .. '&thinsp;)'
elseif station == 'Sky Mill and Water' then
return ' @&thinsp;' .. itemLink('Sky Mill', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;".. '(&thinsp;' .. itemLink('Water', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Sink', {mode = 'image'}) .. '&thinsp;)'
elseif station == 'Sky Mill and Snow Biome' then
return ' @&thinsp;' .. itemLink('Sky Mill', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;".. '[[Tundra]]'
elseif station == 'Placed Bottle only' then
return ' @&thinsp;' .. itemLink('Placed Bottle', {mode = 'image'})
else
return ' @&thinsp;' .. station
end
end
local tableStart = function(title, withStation)
local header_
local str = '<div class="crafts '.. (getArg('class') or '') ..'" id="'.. (getArg('id') or '') ..'"><div class="wrap"><table '
local _id = (getArg('id') or '')
if _id ~= '' then
str = str .. '" id="'.. _id
end
local _css = (getArg('css') or getArg('style') or '')
if _css ~= '' then
str = str .. '" style="'.. _css
end
str = str .. '"><div class="wrap"><table '
if (getArg('sortable') or 'y'):sub(1,1) ~= 'n' then
str = str .. 'class="sortable" '
str = str .. '[[Category:Rezepte-Tabelle mit unerwarteter Gesamtzahl an Zeilen]]'
end
if not expectedrows and rows_count == 0 then
str = str .. '[[Category:Rezepte-Tabelle ohne Zeilen]]'
end
 
--{{{version}}}, normalize
local _versionversion = trimnormalizeVersion(args['version'] or ''):lower()
local version = ''
if _version:find('desktop', 1, true) then
version = version .. ' desktop'
end
if _version:find('console', 1, true) then
version = version .. ' console'
elseif _version:find('konsole', 1, true) then
version = version .. ' console'
end
if _version:find('old-gen', 1, true) then
version = version .. ' old-gen'
end
if _version:find('japan', 1, true) then
version = version .. ' japan'
end
if _version:find('mobile', 1, true) then
version = version .. ' mobile'
elseif _version:find('mobil', 1, true) then
version = version .. ' mobile'
end
if _version:find('3ds', 1, true) then
version = version .. ' 3ds'
end
if version == ' desktop console old-gen mobile 3ds' then
version = ''
elseif version == ' desktop konsole old-gen mobile 3ds' then
version = ''
elseif version == ' desktop console old-gen mobil 3ds' then
version = ''
elseif version == ' desktop konsole old-gen mobil 3ds' then
version = ''
end
 
--store
-- no constraint no result.
if where == '' then
return '<span style="color:red;font-weight:bold;">Keine Eingrenzung in {{rezepte}} festgelegt!</span>'
end
 
end
end -- p.query
 
-- for {{recipes/extract}}
p.extract = function(frame)
currentFrame = frame -- global frame cache
local args = frame:getParent().args
inputArgs = args
 
local where = trim(args['where'] or '')
if where == '' then
where = criStr(args)
end
 
-- no constraint no result.
if where == '' then
return '<span style="color:red;font-weight:bold;">Recipes/extract: No constraint</span>'
end
 
-- query:
local result = mw.ext.cargo.query('Recipes', 'result, resultid, resultimage, resulttext, amount, version, station, args', {
where = where,
groupBy = "resultid, result, amount, version, ings",
orderBy = "result, amount DESC, version", -- Don't order by station
limit = 20, -- enough.
})
 
-- output
local mode = getArg('mode')
local sep = getArg('sep') or getArg('seperator')
if not mode or mode =='compact' or mode == '' then
--default mode = ingredients
local sep = sep or "<br/>'''or'''<br/>"
local withResult = getArg('withresult')
local withStation = not getArg('nostation')
local str = nil
for _, row in ipairs(result) do
if str then
str = str .. sep
else
str = ''
end
str = str .. '<span class="recipe compact">'
local ingFlag = nil
for _, v in ipairs(explode('^', row['args'])) do
if ingFlag then
str = str .. ' + '
else
ingFlag = true
end
local item, amount = v:match('^(.-)¦(.-)$')
if amount ~= '1' then
str = str .. amount .. ' '
end
local s
for _, itemname in ipairs(split(item)) do
if s then
s = s .. "&thinsp;/&thinsp;" .. itemLink(itemname, {mode='image'})
else
s = itemLink(itemname, {mode='image'})
end
end
str = str .. s
end
if withStation then
str = str .. compactStation(row['station'])
end
if withResult then
str = str .. ' = '
if row['amount'] ~= '1' then
str = str .. row['amount'] .. ' '
end
local args = {mode='image'}
if row['resultimage'] then
args['image'] = row['resultimage']
end
str = str .. itemLink(row['result'], args)
end
str = str..'</span>'
end
return str
elseif mode == 'ingredients' then
local sep = sep or "'''or'''"
local str = nil
for _, row in ipairs(result) do
if str then
str = str .. sep
else
str = ''
end
str = str .. ingredientsCell(row['args'])
end
return '<div class="crafting-ingredients">'..str..'</div>'
elseif mode == 'station' then
-- only return first row.
for _, row in ipairs(result) do
return stationCell(row['station'])
end
elseif mode == 'result' then
-- only return first row.
local needCate, needLink = getFlags(args)
for _, row in ipairs(result) do
return resultCell(row, getArg('showresultid'), needLink, true)
end
else
return '<span style="color:red;font-weight:bold;">Recipes/extract: Invalid mode</span>'
end
end -- p.extract
 
return p
3.581

Bearbeitungen