Template talk:ResourceMap

From ARK: Survival Evolved Wiki
Jump to: navigation, search

Improved code structure[edit source]

Since this is full-protected, I'm suggesting the following change instead of simply doing it myself:

Current Suggested
{{#vardefine:title|{{#switch:{{#var:type}}
  |water-vein|water-vein cave=Water Vein
  |oil-vein|oil-vein cave=Oil Vein
  |oil-vein-double|oil-vein-double cave=Double Oil Veins
  |oil-rock|oil-rock cave=Oil Rock
  |salt|salt cave=Salt Deposit
  |sulfur|sulfur cave=Sulfur Deposit
  |crystal|crystal cave=Crystal Deposit
  |obsidian|obsidian cave=Obsidian Deposit
  |silica|silica cave=Silica Deposit
  |metal|metal cave=Metal Deposit
  |metal-rich|metal-rich cave=Rich Metal Deposit
  |metal-underwater=Underwater Metal Deposit
  |river-rock|river-rock cave=River Rock
  |cactus|cactus cave=Cactus
  |black-pearl=Black Pearls
  |rare-flower=Rare Flowers
  |silk=Silk
  |rockarrot=Rockarrot
  |savoroot=Savoroot
  |polymer=Polymer
  |element-ore=Element Ore
  |dust-rich=Rich Dust
  |keratin=Keratin
  |gem-blue=Blue Gem
  |gem-green=Green Gem
  |gem-red=Red Gem
  |charge-node=Charge Node
  |hyper-charge-node=Hypercharge Node
  |gas-node=Gas Vein
  |plant-z=Plant Species Z
  |drake-nest=Rock Drake Nest
  |wyvern-nest=Wyvern Nest
  |dossier=Dossier
  |note=Note
  |artifact=Artifact
  |underwater-dome=Underwater Dome
  |cave-entrance=Cave entrance
  |poi=Point of interest
  |cave-loot=Cave loot crate
  |sea-loot=Deep sea or desert loot crate
  |crate c031525|crate c031530|crate c03153045|crate c0315304555|crate c15253545|crate c25354560|crate c304555|crate c30455570|crate c031525354560|crate c03152535456070|crate c456070|crate special=Beacon loot crate|crate osd=Orbital Supply Drop|crate element=Element Vein
  |crateCave c102535|crateCave c10253550|crateCave c253550|crateCave c355065|crateCave c35506580|crateCave c506580=Cave loot crate
  |crateDungeon d355065|crateDungeon d50|crateDungeon d506580|crateDungeon d65|crateDungeon d6580=Dungeon loot crate
  |crateSurface s35506580=Surface beacon loot crate
  |obelisk-red=Red Obelisk
  |obelisk-blue=Blue Obelisk
  |obelisk-green=Green Obelisk
  |obelisk-yellow=Yellow Obelisk <!-- Mod:Ebenus Astrum -->
  |terminal=Terminal
  |test=Test
  |structure=Structure
  |structure-hidden=Structure hidden
  |tame=Tamed Creature
  |#default=not or wrong specified
}}&#10;lat {{#var:lat}}, lon {{#var:lon}}&#10;{{#explode:{{#var:node}}|,|3}}}}
{{#vardefine:resource|{{#switch:{{#explode:{{#var:type}}}}
  |crate={{#switch:{{#var:type}}
    |crate osd=Orbital Supply Drop
    |crate element=Element Vein
    |crate special=Beacon loot crate<!-- in case a different one is ever wanted -->
    |#default=Beacon loot crate
  }}
  |crateCave=Cave loot crate
  |crateDungeon=Dungeon loot crate
  |crateSurface=Surface beacon loot crate
}}}}{{#if:{{#var:resource}}||{{#vardefine:resource|{{#switch:{{#var:type}}
  |water-vein|water-vein cave=Water Vein
  |oil-vein|oil-vein cave=Oil Vein
  |oil-vein-double|oil-vein-double cave=Double Oil Veins
  |oil-rock|oil-rock cave=Oil Rock
  |salt|salt cave=Salt Deposit
  |sulfur|sulfur cave=Sulfur Deposit
  |crystal|crystal cave=Crystal Deposit
  |obsidian|obsidian cave=Obsidian Deposit
  |silica|silica cave=Silica Deposit
  |metal|metal cave=Metal Deposit
  |metal-rich|metal-rich cave=Rich Metal Deposit
  |metal-underwater=Underwater Metal Deposit
  |river-rock|river-rock cave=River Rock
  |cactus|cactus cave=Cactus
  |black-pearl=Black Pearls
  |rare-flower=Rare Flowers
  |silk=Silk
  |rockarrot=Rockarrot
  |savoroot=Savoroot
  |polymer=Polymer
  |element-ore=Element Ore
  |dust-rich=Rich Dust
  |keratin=Keratin
  |gem-blue=Blue Gem
  |gem-green=Green Gem
  |gem-red=Red Gem
  |charge-node=Charge Node
  |hyper-charge-node=Hypercharge Node
  |gas-node=Gas Vein
  |plant-z=Plant Species Z
  |drake-nest=Rock Drake Nest
  |wyvern-nest=Wyvern Nest
  |dossier=Dossier
  |note=Note
  |artifact=Artifact
  |underwater-dome=Underwater Dome
  |cave-entrance=Cave entrance
  |poi=Point of interest
  |cave-loot=Cave loot crate
  |sea-loot=Deep sea or desert loot crate
  |obelisk-red=Red Obelisk
  |obelisk-blue=Blue Obelisk
  |obelisk-green=Green Obelisk
  |obelisk-yellow=Yellow Obelisk <!-- Mod:Ebenus Astrum -->
  |terminal=Terminal
  |test=Test
  |structure=Structure
  |structure-hidden=Structure hidden
  |tame=Tamed Creature
  |#default=not or wrong specified
}}}}}}{{#vardefine:title|{{#var:resource}}&#10;lat {{#var:lat}}, lon {{#var:lon}}&#10;{{#explode:{{#var:node}}|,|3}}}}

The suggested code moves all of the "crate" handling to its own #switch statement, which allows to avoid having to list every last possible "crate c012345" variant, and thus makes the code more readable and more maintainable. Dinoguy1000 (talk) 18:14, 10 January 2019 (UTC)