Posted 02 April 2017 - 12:56 AM
Hello!
I'm sure there is an easy way to do this… but I can't figure it out for the life of me.
What I am trying to do is create a config file. I have an API that automatically opens the table unserialized, so that I can use what is in the table for my settings in my program etc. The issue for me is how I can "edit" a certain item in the table.
My keys in the table are not numbers (like, table={ [ 1 ]="A value here" }), but they are like variables (table={ something="a value here" }). This works great, but changing a specific item is't going so well.
Okay, the problem is that I want to first remove the item from the table using table.remove(mytable, key), and insert the new "modified" item back into the table using table.insert(mytable, key, value) or something like that. However both table.insert and table.remove ask for numbers, not strings. Is there a way around this?
Also, when inserting an item into a table, is there a way to insert an item like a variable that contains a value (like how I have my table set up originally)?
Thanks! I will appreciate anyone's help. I can provide any extra information or pictures if needed. I just want this resolved at some point.
I'm sure there is an easy way to do this… but I can't figure it out for the life of me.
What I am trying to do is create a config file. I have an API that automatically opens the table unserialized, so that I can use what is in the table for my settings in my program etc. The issue for me is how I can "edit" a certain item in the table.
My keys in the table are not numbers (like, table={ [ 1 ]="A value here" }), but they are like variables (table={ something="a value here" }). This works great, but changing a specific item is't going so well.
Okay, the problem is that I want to first remove the item from the table using table.remove(mytable, key), and insert the new "modified" item back into the table using table.insert(mytable, key, value) or something like that. However both table.insert and table.remove ask for numbers, not strings. Is there a way around this?
Also, when inserting an item into a table, is there a way to insert an item like a variable that contains a value (like how I have my table set up originally)?
Thanks! I will appreciate anyone's help. I can provide any extra information or pictures if needed. I just want this resolved at some point.