Anonymous user
Module:Inventory slot: Difference between revisions
m
Added item sets ("Any Wool" and "Any Planks")
imported>Ttv pedro270707 mNo edit summary |
imported>Ttv pedro270707 m (Added item sets ("Any Wool" and "Any Planks")) |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
p.itemSets = { | |||
["Any Wool"] = { | |||
"White Wool", | |||
"Orange Wool", | |||
"Magenta Wool", | |||
"Light Blue Wool", | |||
"Yellow Wool", | |||
"Lime Wool", | |||
"Pink Wool", | |||
"Gray Wool", | |||
"Light Gray Wool", | |||
"Cyan Wool", | |||
"Purple Wool", | |||
"Blue Wool", | |||
"Brown Wool", | |||
"Green Wool", | |||
"Red Wool", | |||
"Black Wool" | |||
}, | |||
["Any Planks"] = { | |||
"Wooden Planks", | |||
"White Wooden Planks", | |||
"Orange Wooden Planks", | |||
"Magenta Wooden Planks", | |||
"Light Blue Wooden Planks", | |||
"Yellow Wooden Planks", | |||
"Lime Wooden Planks", | |||
"Pink Wooden Planks", | |||
"Gray Wooden Planks", | |||
"Light Gray Wooden Planks", | |||
"Cyan Wooden Planks", | |||
"Purple Wooden Planks", | |||
"Blue Wooden Planks", | |||
"Brown Wooden Planks", | |||
"Green Wooden Planks", | |||
"Red Wooden Planks", | |||
"Black Wooden Planks" | |||
} | |||
} | |||
function p.createSlot( f ) | function p.createSlot( f ) | ||
| Line 32: | Line 72: | ||
} | } | ||
for i, value in ipairs(p.parseString( args.item )) do | for i, value in ipairs(p.parseString( args.item )) do | ||
local name = value.name | local name = value.name | ||
local item = value.item | local item = value.item | ||
local link = nil | if p.itemSets[item] then | ||
for j, subvalue in ipairs(p.itemSets[item]) do | |||
local display = i == j == 1 and "display: inline-block" or "display: none" | |||
local link = nil | |||
local slot = mw.html.create( "div" ) | |||
slot:addClass( "minecraft-item" ) | |||
:cssText( table.concat( slotCss, ";" ) ) | |||
:attr( "data-mctitle", (name == item and subvalue or name) ) | |||
slot:wikitext( sprite( { data = "InvSprite", id = item } ) ) | |||
if item ~= pageName and subvalue then | |||
link = subvalue | |||
end | |||
if link and mw.title.new( link ).exists then | |||
slotContainer:wikitext( "<span style='" .. display .. "'>" .. "[[" .. link .. "|" .. tostring( slot ) .. "]]" .. "</span>" ) | |||
else | |||
slotContainer:wikitext( "<span style='" .. display .. "'>" .. tostring( slot ) .. "</span>" ) | |||
end | |||
end | |||
else | else | ||
slotContainer:wikitext( "<span style='" .. display .. "'>" .. tostring( slot ) .. "</span>" ) | local display = i == 1 and "display: inline-block" or "display: none" | ||
local link = nil | |||
local slot = mw.html.create( "div" ) | |||
slot:addClass( "minecraft-item" ) | |||
:cssText( table.concat( slotCss, ";" ) ) | |||
:attr( "data-mctitle", name ) | |||
slot:wikitext( sprite( { data = "InvSprite", id = item } ) ) | |||
if item ~= pageName and item then | |||
link = item | |||
end | |||
if link and mw.title.new( link ).exists then | |||
slotContainer:wikitext( "<span style='" .. display .. "'>" .. "[[" .. link .. "|" .. tostring( slot ) .. "]]" .. "</span>" ) | |||
else | |||
slotContainer:wikitext( "<span style='" .. display .. "'>" .. tostring( slot ) .. "</span>" ) | |||
end | |||
end | end | ||
end | end | ||