Anonymous user
Module:Inventory slot: Difference between revisions
m
Made it so that parseString() returns a nil name now, allowing "Any Wool" or "Any Planks" to be an item name
imported>Ttv pedro270707 m (Added item sets ("Any Wool" and "Any Planks")) |
imported>Ttv pedro270707 m (Made it so that parseString() returns a nil name now, allowing "Any Wool" or "Any Planks" to be an item name) |
||
| Line 81: | Line 81: | ||
slot:addClass( "minecraft-item" ) | slot:addClass( "minecraft-item" ) | ||
:cssText( table.concat( slotCss, ";" ) ) | :cssText( table.concat( slotCss, ";" ) ) | ||
:attr( "data-mctitle", (name | :attr( "data-mctitle", (name or subvalue) ) | ||
slot:wikitext( sprite( { data = "InvSprite", id = | slot:wikitext( sprite( { data = "InvSprite", id = subvalue } ) ) | ||
if item ~= pageName and subvalue then | if item ~= pageName and subvalue then | ||
link = subvalue | link = subvalue | ||
| Line 99: | Line 99: | ||
slot:addClass( "minecraft-item" ) | slot:addClass( "minecraft-item" ) | ||
:cssText( table.concat( slotCss, ";" ) ) | :cssText( table.concat( slotCss, ";" ) ) | ||
:attr( "data-mctitle", name ) | :attr( "data-mctitle", (name or item) ) | ||
slot:wikitext( sprite( { data = "InvSprite", id = item } ) ) | slot:wikitext( sprite( { data = "InvSprite", id = item } ) ) | ||
if item ~= pageName and item then | if item ~= pageName and item then | ||
| Line 117: | Line 117: | ||
function p.parseString(input) | function p.parseString(input) | ||
local strings = {} | |||
for str in input:gmatch("[^;]+") do | |||
table.insert(strings, str:match("^%s*(.-)%s*$")) | |||
end | |||
local result = {} | |||
for _, str in ipairs(strings) do | |||
local name, item = str:match("^%[(.-)%](.*)$") | |||
if name then | |||
table.insert(result, { name = name:gsub("^%s*(.-)%s*$", "%1"), item = item:gsub("^%s*(.-)%s*$", "%1") }) | |||
else | |||
table.insert(result, { name = nil, item = str:gsub("^%s*(.-)%s*$", "%1") }) | |||
end | |||
end | |||
return result | |||
end | end | ||
return p | return p | ||