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 `len(Enum)` and `Enum.toArray()` #343

Closed netux closed 8 months ago

netux commented 8 months ago

Together, both functions allow for iterating over all values in an enum:

enum MyEnum:
    A = "this is A",
    B = 10,
    C

globalvar i

rule "":
    for i in range(len(MyEnum)):
        printLog(MyEnum.toArray()[i])
variables {
    global:
        0: i
}
rule ("") {
    event {
        Ongoing - Global;
    }
    actions {
        For Global Variable(i, 0, 3, 1);
            Log To Inspector(Value In Array(Array(Custom String("this is A", Null, Null, Null), 10, 11), Global.i));
        End;
    }
}