Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What's the best way to store and reuse Enum Values in a Value Instance?

Asked by 5 years ago

Title describes it all.

I am trying to store an EnumItem object as a Value object. I plan to use it to store keycodes. Such as Enum.KeyCode.E

Now, the problem is that: It is not possible to store EnumItem in values easily. The closest way would be to use IntValues and using the Value of the Enums to work with it. But that's just a waste of code to retrieve back the original Enum even if I know what type it is.

Though, I could change my code to check for Enum Values of a keypress, but BindActionContext requires you to specify Enums. Which is just counter intuitive.....

Also, seems like Enum are seperate object types, as doing Enum.KeyCode.E == Enum.KeyCode.E.Value returns false.

0
In the last comparison at the end you're comparing 'Enum.KeyCode.E.Value' to 'Enum.KeyCode.E', which are two different things. 'Value' returns the numeric representation of the Enum, whereas 'KeyCode.E' is the enum object. ScriptGuider 5640 — 5y
0
true facts DeceptiveCaster 3761 — 5y
0
"Enum" is the classification of the given key on a standard QWERTY keyboard DeceptiveCaster 3761 — 5y
0
Actually, you're wrong MCRobloxUnited. Enum isn't a classicication of a given key. It can be a classification of many other type of objects. and it doesn't have to be a key code. The question is, how would you store them and reuse them as an Enum Key? NathanAdhitya 124 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

have 2 stringvalues, 1 of them for the name of the enumeration, the second for the value, to load them:

local enumeration = script.Parent.CoOlEnUm.Value
local enumvalue = script.Parent.cOoLvAlUe.Value

local final = Enum[enumeration][enumvalue]
0
That seems well enough for temporary, but wouldn't be doing that in bulk be a waste of memory? NathanAdhitya 124 — 5y
0
maybe you could use binarystringvalues? it compresses the strings, but then again. some hidden services have ridiculous amount of instances in them fanofpixels 718 — 5y
Ad

Answer this question