Module:Inventory slot/Aliases: Difference between revisions
+ Any Overworld Planks |
Revamp nether/overworld stem/log related things. Nether fence etc. are removed, but if needed you can put it back with $world. |
||
| Line 15: | Line 15: | ||
['Any netherite armor'] = { 'Netherite Helmet', 'Netherite Chestplate', 'Netherite Leggings', 'Netherite Boots' }, | ['Any netherite armor'] = { 'Netherite Helmet', 'Netherite Chestplate', 'Netherite Leggings', 'Netherite Boots' }, | ||
-- stones -- | -- stones -- | ||
['Any Cobblestone or Blackstone'] = { 'Cobblestone', 'Blackstone' }, | ['Any Cobblestone or Blackstone'] = { 'Cobblestone', 'Blackstone' }, | ||
| Line 322: | Line 299: | ||
['Roots'] = { 'Crimson Roots', 'Warped Roots' }, | ['Roots'] = { 'Crimson Roots', 'Warped Roots' }, | ||
['Nylium'] = { 'Crimson Nylium', 'Warped Nylium' }, | ['Nylium'] = { 'Crimson Nylium', 'Warped Nylium' }, | ||
['Soul Sand'] = { 'Soul Sand', 'Soul Soil' }, | ['Soul Sand'] = { 'Soul Sand', 'Soul Soil' }, | ||
['Campfire'] = { 'Campfire', 'Soul Campfire' }, | ['Campfire'] = { 'Campfire', 'Soul Campfire' }, | ||
| Line 340: | Line 304: | ||
['Stone Button'] = { 'Stone Button', 'Polished Blackstone Button' }, | ['Stone Button'] = { 'Stone Button', 'Polished Blackstone Button' }, | ||
['Stone Pressure Plate'] = { 'Stone Pressure Plate', 'Polished Blackstone Pressure Plate' }, | ['Stone Pressure Plate'] = { 'Stone Pressure Plate', 'Polished Blackstone Pressure Plate' }, | ||
} | } | ||
table.insert( itemVariants['Dye'], 1, 'White Dye' ) | table.insert( itemVariants['Dye'], 1, 'White Dye' ) | ||
| Line 696: | Line 658: | ||
-- Wood -- | -- Wood -- | ||
local | local woodTypes = { | ||
overworld = { | |||
'Oak', | |||
'Spruce', | |||
'Birch', | |||
'Jungle', | |||
'Acacia', | |||
'Dark Oak', | |||
}, | |||
nether = { | |||
'Crimson', | |||
'Warped' | |||
}, | |||
both = {}, | |||
} | } | ||
local woodTypeWorld = {} | |||
for world, woods in pairs(woodTypes) do | |||
for _, type in ipairs(woods) do | |||
woodTypeWorld[type] = world | |||
table.insert(woodTypes.both, type) | |||
end | |||
end | |||
local woodItems = { | local woodItems = { | ||
overworld = { | |||
'Wood', | |||
'Log', | |||
'Boat', | |||
'Stripped $1 Log', | |||
'Stripped $1 Wood', | |||
'Wood Planks', | |||
'Wood Slab', | |||
'Sapling', | |||
}, | |||
nether = { | |||
'Stem', | |||
'Hyphae', | |||
'Stripped $1 Stem', | |||
'Stripped $1 Hyphae', | |||
}, | |||
both = { | |||
'$world Planks', | |||
'${Wood,Hyphae}', | |||
'${Log,Stem}', | |||
'Stripped $1 ${Wood,Hyphae}', | |||
'Stripped $1 ${Log,Stem}', | |||
'Fence Gate', | |||
'$world Wood Fence', | |||
'$wood fence', | |||
'$wood Button', | |||
'$wood Pressure Plate', | |||
'$wood Trapdoor', | |||
'$world $wood Slab', | |||
'$wood Stairs', | |||
'Sign' | |||
} | |||
} | } | ||
local woodItemWorld = {} | |||
for world, items in pairs(woodItems) do | |||
for _, item in ipairs(items) do | |||
-- expand $world (should only happen in "both") | |||
if (item:find('%$world')) and world == 'both' then | |||
item = string.gsub(item, '%$world ', '') | |||
woodItemWorld['Overworld ' .. item] = 'overworld' | |||
woodItemWorld['Nether ' .. item] = 'nether' | |||
end | |||
woodItemWorld[item] = world | |||
end | |||
end | |||
for | for item, world in pairs(woodItemWorld) do | ||
local itemName = '' | local itemName = '' | ||
local woodAliases = {} | local woodAliases = {} | ||
for _, wood in ipairs( | -- real "linkable" name | ||
if | local realItem = string.gsub(item, '^Overworld ', '') | ||
itemName = string.gsub( | realItem = string.gsub(realItem, '^Nether ', '') | ||
elseif | |||
itemName = string.gsub( | for _, wood in ipairs(woodTypes[world]) do | ||
-- Parse ${,} (world-select) syntax | |||
local selector = woodTypeWorld[wood] == 'overworld' and "%1" or "%2" | |||
realItem = string.gsub(realItem, "%${(.-),(.-)}", selector) | |||
if realItem:find('%$wood') then | |||
itemName = string.gsub(realItem, '%$wood', wood) | |||
elseif realItem:find('%$1') then | |||
itemName = string.gsub(realItem, '%$1', wood) | |||
else | else | ||
itemName = wood .. ' ' .. item | itemName = wood .. ' ' .. item | ||
end | end | ||
table.insert( woodAliases, itemName ) | table.insert(woodAliases, itemName) | ||
end | end | ||
item = string.gsub( item, '%$1 ', '' ) | -- Parse ${,} (world-select) syntax | ||
item = string.gsub(item, "%${(.-),(.-)}", "%1 or %2") | |||
item = string.gsub(item, '%$wood ', 'Wood ') | |||
item = string.gsub(item, '%$1 ', '') | |||
aliases['Any ' .. item] = woodAliases | |||
aliases['Matching ' .. item] = woodAliases | aliases['Matching ' .. item] = woodAliases | ||
end | end | ||