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 = | 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 = | aliases[name] = { name = potionName, text = effect.text:gsub( '%$1', durations[1] ) } | ||
aliases[name .. ' Extended'] = { name = potionName, text = | aliases[name .. ' Extended'] = { name = potionName, text = effect.text:gsub( '%$1', durations[2] ) } | ||
aliases[name .. ' Enhanced'] = { name = potionName, text = | 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 = | 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 = | local realItem = item:gsub('^Overworld ', '') | ||
realItem = | 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 = | realItem = mw.ustring.gsub(realItem, "%${(.-),(.-)}", selector) | ||
if realItem:find('%$wood') then | if realItem:find('%$wood') then | ||
itemName = | itemName = realItem:gsub('%$wood', wood) | ||
elseif realItem:find('%$1') then | elseif realItem:find('%$1') then | ||
itemName = | 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 = | item = item:gsub("%${(.-),(.-)}", "%1 or %2") | ||
item = | item = item:gsub('%$wood ', 'wood ') | ||
item = | item = item:gsub(item, '%$1 ', '') | ||
aliases['Any ' .. item] = woodAliases | aliases['Any ' .. item] = woodAliases | ||
aliases['Matching ' .. item] = woodAliases | aliases['Matching ' .. item] = woodAliases | ||