Have you every wanted enums in blocks? To be able to save the state of your player or game, but as a number? Introducing enum-blocks!
add enumerations to blocks!
blocks it adds:
setEnumVar / setEnumVarStatement - sets/adds a key to an enum, with an optional number (details to last+1).
getEnumVar - gets the number assigned to a key in an enum.
enumVar - same as getEnumVar, but if the key doesn’t exist, it will create it for you.
enumStr - gets the name of a key, which normal enums do not have.
test projects (same thing but different code, the first uses set/getEnumVar while the second uses enumVar):
1 Like
Such a cool extension! Now I don’t have to see so many “magic numbers” in my friends enemy/ai state! I’m going to tell him about this extension as soon as I can!
2 Likes
YamJam
July 28, 2026, 2:03am
3
This would be heavenly if it weren’t for richards state extension
1 Like
I thought so but that one technically only contained one enum if that makes sense. This one allows multiple like PlayerAnims, EnemyAnims, GameState, etc.
2 Likes
what is his state extension?
2 Likes
Hey @VoxelMaster64 , could you make it so that basically you could have arrays in enums. Like a
enum that can have arrays in it?
Example:
enum MyGroup {
Animals,
Fruits,
Tools
}
EnumArray.set(MyGroup.Animals, ["cat", "dog", "bird"])
EnumArray.set(MyGroup.Fruits, ["apple", "banana", "grape"])
EnumArray.set(MyGroup.Tools, ["hammer", "saw", "wrench"])
Block ideas:
set group Animals to array […]
get value # from group Fruits
length of group Tools
group Fruits contains “banana”
Also, could you make blocks that make it so that you can have like a “nested enum”; enums inside of enums?
I was thinking of doing like a set(name: string, data: any) but makecode hates any. any[] is completely safe though. I don’t know how to fix it.
1 Like