Zezombye / overpy

High-level language for the Overwatch Workshop with support for compilation and decompilation.
GNU General Public License v3.0
175 stars 25 forks source link

Add __splitObjectArray__ #353

Open Zezombye opened 7 months ago

Zezombye commented 7 months ago
 __splitObjectArray__({
    hero: waveHeroes,
    length: waveLengths
}, [
    {
        hero: Hero.ANA,
        length: 3,
    }, {
        length: 8,
        hero: Hero.SOLDIER,
    }, {
        hero: Hero.HAMMOND,
    }
])

->

waveHeroes = [Hero.ANA, Hero.SOLDIER, Hero.HAMMOND]
waveLengths = [3, 8, null]

Replaces the need to use a JS macro for this commonly used programming pattern.

Throw an error if one of the objects has a key not referenced in the variables dict. If a key is missing, set it to null.