Module:Inventory slot/Aliases: Difference between revisions

mNo edit summary
Maybe ustring will be right?
Line 507: Line 507:
for _, color in ipairs( colors ) do
for _, color in ipairs( colors ) do
if item:find( '%$1' ) then
if item:find( '%$1' ) then
itemName = string.gsub( item, '%$1', color )
itemName = item:gsub( '%$1', color )
else
else
itemName = color .. ' ' .. item
itemName = color .. ' ' .. item
Line 623: Line 623:
-- turtle master is weird, so just do a fancy string replacement
-- turtle master is weird, so just do a fancy string replacement
if effect.text then
if effect.text then
aliases[name] = { name = potionName, text = string.gsub( effect.text, '%$1', durations[1] ) }
aliases[name] = { name = potionName, text = effect.text:gsub( '%$1', durations[1] ) }
aliases[name .. ' Extended'] = { name = potionName, text = string.gsub( effect.text, '%$1', durations[2] ) }
aliases[name .. ' Extended'] = { name = potionName, text = effect.text:gsub( '%$1', durations[2] ) }
aliases[name .. ' Enhanced'] = { name = potionName, text = string.gsub( effect.enhanced, '%$1', durations[3] ) }
aliases[name .. ' Enhanced'] = { name = potionName, text = effect.enhanced:gsub( '%$1', durations[3] ) }
else
else
-- we always have normal
-- we always have normal
Line 721: Line 721:
-- expand $world (should only happen in "both")
-- expand $world (should only happen in "both")
         if (item:find('%$world')) and world == 'both' then
         if (item:find('%$world')) and world == 'both' then
             item = string.gsub(item, '%$world ', '')
             item = item:gsub('%$world ', '')
             woodItemWorld['Overworld ' .. item] = 'overworld'
             woodItemWorld['Overworld ' .. item] = 'overworld'
woodItemWorld['Nether ' .. item] = 'nether'
woodItemWorld['Nether ' .. item] = 'nether'
Line 734: Line 734:


-- real "linkable" name
-- real "linkable" name
     local realItem = string.gsub(item, '^Overworld ', '')
     local realItem = item:gsub('^Overworld ', '')
     realItem = string.gsub(realItem, '^Nether ', '')
     realItem = realItem:gsub('^Nether ', '')


for _, wood in ipairs(woodTypes[world]) do
for _, wood in ipairs(woodTypes[world]) do
-- Parse ${,} (world-select) syntax
-- Parse ${,} (world-select) syntax
local selector = (woodTypeWorld[wood] == 'overworld') and "%1" or "%2"
local selector = (woodTypeWorld[wood] == 'overworld') and "%1" or "%2"
realItem = string.gsub(realItem, "%${(.-),(.-)}", selector)
realItem = mw.ustring.gsub(realItem, "%${(.-),(.-)}", selector)


if realItem:find('%$wood') then
if realItem:find('%$wood') then
itemName = string.gsub(realItem, '%$wood', wood)
itemName = realItem:gsub('%$wood', wood)
elseif realItem:find('%$1') then
elseif realItem:find('%$1') then
itemName = string.gsub(realItem, '%$1', wood)
itemName = realItem:gsub( '%$1', wood)
else
else
itemName = wood .. ' ' .. realItem
itemName = wood .. ' ' .. realItem
Line 753: Line 753:


-- Parse ${,} (world-select) syntax
-- Parse ${,} (world-select) syntax
item = string.gsub(item, "%${(.-),(.-)}", "%1 or %2")
item = item:gsub("%${(.-),(.-)}", "%1 or %2")
     item = string.gsub(item, '%$wood ', 'wood ')
     item = item:gsub('%$wood ', 'wood ')
     item = string.gsub(item, '%$1 ', '')
     item = item:gsub(item, '%$1 ', '')
     aliases['Any ' .. item] = woodAliases
     aliases['Any ' .. item] = woodAliases
aliases['Matching ' .. item] = woodAliases
aliases['Matching ' .. item] = woodAliases