|
| 25 Aug 2016 08:39 AM |
I made a system to change keybindings in roblox and I want to save your settings, however, you can't save Enums. So I have the idea to just convert it into a string and then save it, but I have no idea how to convert it back once you load it in again. Anyone got an idea on how I could do this? |
|
|
| Report Abuse |
|
|
Laedere
|
  |
| Joined: 17 Jun 2013 |
| Total Posts: 23601 |
|
|
| 25 Aug 2016 08:40 AM |
Maybe Enum.KeyCode["String"]
|
|
|
| Report Abuse |
|
|
|
| 25 Aug 2016 08:43 AM |
print(input.KeyCode == Enum.KeyCode[keystring]) This prints true, so I think it will work, thanks! |
|
|
| Report Abuse |
|
|
Objectly
|
  |
| Joined: 18 Jul 2016 |
| Total Posts: 210 |
|
|
| 25 Aug 2016 08:44 AM |
| Save your string values in a dictionary with [string] = enum or you can have a dictionary that has the strings as indexes with the enums that you can access whenever you want those enums. |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2016 08:50 AM |
^ I wanted to save those enums to datastores, and datastores can only save numbers, strings and tables, so that's why I needed to convert them. Also, I'm still not sure if you can save dictionnaries, but I know that I've had a lot of trouble with them in the past, so I'm using regular tables :) |
|
|
| Report Abuse |
|
|
Objectly
|
  |
| Joined: 18 Jul 2016 |
| Total Posts: 210 |
|
|
| 25 Aug 2016 08:52 AM |
You can have a module that stores the enums instead of a datastore.
|
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 25 Aug 2016 08:55 AM |
| Dictionaries and arrays and mixed keys are all "regular tables". Regular tables are more a general term for when you don't know what the table contains for keys. They're all data structures. As for if you were having issues it was likely 100% an issue you could of worked around. ###p://wiki.roblox.com/index.php?title=Data_store#Tables_with_mixed_list_.2F_record_style_will_be_cut_off |
|
|
| Report Abuse |
|
|
UFAIL2
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 6905 |
|
|
| 25 Aug 2016 08:56 AM |
| *A table is just the general term; doesn't matter what the table contains for keys |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2016 09:00 AM |
| Yeah, at the time I was struggeling with these, I've been on the wiki searching for a long time, reread the whole thing a couple of times because I really wasn't sure what I was doing wrong... However, I don't need a dictionnary now, a table with numbers as keys is sufficient. |
|
|
| Report Abuse |
|
|