Änderungen

Wechseln zu: Navigation, Suche

Modul:Recipes

1.678 Bytes hinzugefügt, vor 1 Jahr
+Modi „ingredients-buy“ / „ingredients-sell“
['Crystal Ball and Water'] = 'Crystal Ball and Water or Sink',
['Sky Mill and Water'] = 'Sky Mill and Water or Sink',
['Sky Mill and Snow Biome'] = 'Sky Mill and Snow Biome',
['Crystal Ball and Honey'] = 'Crystal Ball and Honey',
['Crystal Ball and Lava'] = 'Crystal Ball and Lava',
},
-- for {{recipes/extract}}--
['Crystal Ball and Water'] = '水晶球和水或水槽',
['Sky Mill and Water'] = '天磨和水或水槽',
['Sky Mill and Snow Biome'] = '天磨和雪原生物群落',
['Crystal Ball and Honey'] = '水晶球和蜂蜜',
['Crystal Ball and Lava'] = '水晶球和熔岩',
for _, row in ipairs(result) do
return resultCell(row, getArg('showresultid'), needLink, true, getArg('resulttemplate'))
end
elseif mode == 'ingredients-buy' then
-- only process first row.
for _, row in ipairs(result) do
local value = 0
for _, v in ipairs(explode('^', row['args'])) do
local item, amount = v:match('^(.-)¦(.-)$')
value = value + require('Module:Iteminfo').getItemStat( tonumber(currentFrame:expandTemplate{ title = 'itemIdFromName', args = {item, lang='en'} }) or 0, 'value' ) * amount
end
return value
end
elseif mode == 'ingredients-sell' then
-- only process first row.
for _, row in ipairs(result) do
local value = 0
for _, v in ipairs(explode('^', row['args'])) do
local item, amount = v:match('^(.-)¦(.-)$')
value = value + math.floor(require('Module:Iteminfo').getItemStat( tonumber(currentFrame:expandTemplate{ title = 'itemIdFromName', args = {item, lang='en'} }) or 0, 'value' )/5) * amount
end
return value
end
else
end -- p.extract
 
-- count
p.count = function(frame)
local args = frame:getParent().args
local where = trim(args['where'] or '')
if where == '' then
where = criStr(args)
end
-- no constraint no result.
if where == '' then
return
end
-- query: since we must use group by to eliminate duplicates, so we can not use COUNT() to get row count directly.
local result = mw.ext.cargo.query('Recipes', 'result, resultid, resultimage, resulttext, amount, version, station, args', {
where = where,
groupBy = "resultid, result, amount, ings, version",
limit = 2000,
})
-- count
local count = 0
for _, row in ipairs(result) do
count = count + 1
end
return count
end -- p.count
 
-- return "yes" or ""
p.exist = function(frame)
local args = frame:getParent().args
local where = trim(args['where'] or '')
if where == '' then
3.577

Bearbeitungen