No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
| Line 39: | Line 39: | ||
tableText = tableText .. [[ | tableText = tableText .. [[ | ||
}}]] | }}]] | ||
return | return tableText2 | ||
end | end | ||
Revision as of 09:41, 4 November 2024
This module uses the data from Module:Crafting_DB to create a exhibition of all the craftable items of the game
{{#invoke:Lua|crafting}}
{{tabs |name1= test |tab1= something }}
u = require("Module:Util")
db = require("Module:Crafting_DB")
inspect = require("Module:InspectLua")
local p = {}
local groups = {'Furnace','Oven','Statue','Oil Well','Community Center','Oil Silo','Arrow','Mining Machinery','Boat','Fight Points Medallion','Weapon','Tool'}
function p.craftingTable()
local tableText = '{{tabs'
local tableText2 = [[{{tabs
]] .. "{{!}}name" .. 1 .. "= test" .. [[
]] .. "{{!}}tab" .. 1 .. "= something" .. [[
}}]]
for groupIndex, group in ipairs(groups) do
local recipes = {}
local itemIndex = 0
for _, e in ipairs(db) do
if e[6] == groupIndex then
itemIndex = itemIndex + 1
if not recipes[itemIndex] then
recipes[itemIndex] = {
item = e[1],
itemImage = e[2],
level = e[3],
description = e[7],
xp = e[4],
materials = {}
}
end
for _, f in ipairs(e[5]) do
table.insert(recipes[itemIndex].materials, f)
end
end
end
tableText = tableText .. "\n" .. "{{!}}name" .. groupIndex .. "=" .. groups[groupIndex] .. [[
]] .. "{{!}}tab" .. groupIndex .. "=" .. p.table(recipes)
end
tableText = tableText .. [[
}}]]
return tableText2
end
function p.table(recipes)
result = [[
{| class="wikitable sortable"
! colspan="2" style="width: 30%" |Item
! Level Needed
! style="width: 20%" |Materials
! style="width: 25%" |Description
!XP
]]
for _, e in pairs(recipes) do
local materialStr = ''
for i, m in ipairs(e.materials) do
materialStr = materialStr .. u.c(m[2]) .. " " .. '[[' .. m[1] .. ']]'
materialStr = materialStr .. "<br>"
end
result = result .. [[
|-
|]] .. '[[File: ' .. e.itemImage .. '.png|35px|link=' .. e.item .. ']]' .. [[
|]] .. '[[' .. e.item .. ']]' .. [[
|]] .. e.level .. '[[File:CraftingSigil.png|20px|link=]]' .. [[
|]] .. materialStr .. [[
|]] .. e.description .. [[
|]] .. u.c(e.xp) .. 'xp' .. [[
]]
end
return result .. [[
|}
]]
end
return p