mNo edit summary |
mNo edit summary |
||
Line 101: | Line 101: | ||
table.insert(lines, '| ' .. tostring(v.id)) |
table.insert(lines, '| ' .. tostring(v.id)) |
||
for _, r in pairs(recipes) do |
for _, r in pairs(recipes) do |
||
− | table.insert(lines, '| <div " |
+ | table.insert(lines, '| <div "crafting-recipe">' .. compToImg(r, 1) .. compToImg(r, 2) .. compToImg(r, 3) .. compToImg(r, 4) .. compToImg(r, 5) .. compToImg(r, 6) .. compToImg(r, 7) .. compToImg(r, 8) .. '</div>') |
end |
end |
||
end |
end |
Revision as of 08:16, 16 October 2021
Documentation for this module may be created at Module:Bag of crafting recipes/doc
local p = {}
local cargo = mw.ext.cargo
local w_frame = require( 'module:frame' )
local itemRecipes = mw.loadData( 'module:Bag_of_crafting_recipes/data' )
local toolTips = {
[1] = 'Red Heart (1)',
[2] = 'Soul Heart (2)',
[3] = 'Black Heart (3)',
[4] = 'Eternal Heart (4)',
[5] = 'Golden Heart (5)',
[6] = 'Bone Heart (6)',
[7] = 'Rotten Heart (7)',
[8] = 'Penny (8)',
[9] = 'Nickel (9)',
[10] = 'Dime (10)',
[11] = 'Lucky Penny (11)',
[12] = 'Key (12)',
[13] = 'Golden Key (13)',
[14] = 'Charged Key (14)',
[15] = 'Bomb (15)',
[16] = 'Golden Bomb (16)',
[17] = 'Mega Bomb (17)',
[18] = 'Micro Battery (18)',
[19] = 'Lil Battery (19)',
[20] = 'Mega Battery (20)',
[21] = 'Card (21)',
[22] = 'Pill (22)',
[23] = 'Rune (23)',
[24] = 'Dice Shard (24)',
[25] = 'Cracked Key (25)',
[26] = 'Unused (26)',
}
function compToImg(s, i)
local id = s:byte(i) - 0x61
return '[[file:Collectible Bag of Crafting component ' .. tostring(id) .. '.png|' .. toolTips[id] .. ']]'
end
function recipeToTable(r)
local lines = {}
table.insert(lines, '{| class="wikitable"')
table.insert(lines, '|-')
table.insert(lines, '| ' .. compToImg(r, 1) .. ' || '.. compToImg(r, 2) .. ' || '.. compToImg(r, 3) .. ' || '.. compToImg(r, 4))
table.insert(lines, '|-')
table.insert(lines, '| ' .. compToImg(r, 5) .. ' || '.. compToImg(r, 6) .. ' || '.. compToImg(r, 7) .. ' || '.. compToImg(r, 8))
table.insert(lines, '|}')
return table.concat(lines, '\n')
end
function p.tableOfRecipes(f)
return '|-\n| Recipes unavailable at this time'
end
--[[ function commented out, pages are unloadable
local args = w_frame.args( f )
local lines = {}
local is_active = args[1] == '1'
local min = tonumber(args[2])
local max = tonumber(args[3])
local qres = cargo.query('collectible', '_pageName = page, dlc, alias, name, image, id, quote, is_activated, description, recharge, quality, tags', {
where = 'id >= ' .. tostring(min) .. ' AND id < ' .. tostring(max) .. ' AND is_activated='..tostring(is_active),
orderBy = 'id',
limit = 800,
})
-- Expand the row templates once per item
for _, v in ipairs(qres) do
local recipes = itemRecipes[tonumber(v.id)]
if recipes ~= nil then
table.insert(lines, '|-')
table.insert(lines, '| ' .. f:expandTemplate({title='i/query', args=v}))
table.insert(lines, '| ' .. tostring(v.id))
for _, recipe in pairs(recipes) do
table.insert(lines, '| ')
table.insert(lines, recipeToTable(recipe))
end
end
end
return table.concat(lines, '\n')
end
]]--
function p.tableOfRecipesTest(f)
local args = w_frame.args(f)
local frame = mw.getCurrentFrame()
local lines = {}
local qres = cargo.query('collectible', '_pageName = page, dlc, alias, name, image, id', {
where = 'id >= ' .. args[2] .. ' AND id < ' .. args[3] .. ' AND is_activated=' .. args[1],
orderBy = 'id',
limit = 800
})
-- Expand the row templates once per item
for _, v in ipairs(qres) do
local recipes = itemRecipes[tonumber(v.id)]
if recipes ~= nil then
table.insert(lines, '|-')
table.insert(lines, '| ' .. frame:expandTemplate({title='i/query', args=v}))
table.insert(lines, '| ' .. tostring(v.id))
for _, r in pairs(recipes) do
table.insert(lines, '| <div "crafting-recipe">' .. compToImg(r, 1) .. compToImg(r, 2) .. compToImg(r, 3) .. compToImg(r, 4) .. compToImg(r, 5) .. compToImg(r, 6) .. compToImg(r, 7) .. compToImg(r, 8) .. '</div>')
end
end
end
return table.concat(lines, '\n')
end
return p