How do I return the name of an object within a storage array?
I have a storage array blocks with the form [{oak_log:1},{hay_block:2},{diamond_block:3}] where each block has a value associated to it. I want to be able to access both the block type and value with a single number. e.g I put in 2 and get a value of hay block and a separate value of 2 (the value of the hay block). So far I've figured out I can use blocks[2] to get {hay_block:2} and blocks[2].hay_block to get my value of 2. but I need to somehow return hay_block by itself first.
Thanks in advance for the help!