Thanks for the addition of this section!
As for “Convert an Object’s Name to a Reference” - I’ve implemented this in my code as well, but thought the following might help clarify a few things.
First, it seems like there is a pathArray = split(pathString, ".")
missing somewhere, or at least it seems like it should be happening outside of the function call, but it maybe helpful to include as the example states “if the string is ‘myclass.mytable.myelement’, the function will return a reference…”.
Second, it is extremely important to note that this function, in its current implementation, will not always return a reference, but will return the element at that location. If that element happens to be a reference, such as in the case of a table, the elements of that table can be altered, but simply replacing the table will have no effect.
For example, imagine I had a table structured as the following:
mytable: { mystring: "my string", mynumber: 5, mynestedtable: { a: "regular table" } }
The following code would produce the resulting output:
`
local stringRef = resolveReference(“mytable.mystring”);
stringRef = “my new string”;
server.log(resolveReference(“mytable.mystring”) //prints “my string”
local numRef = resolveReference(“mytable.mynumber”);
numRef = 10;
server.log(resolveReference(“mytable.mynumber”) //prints 5
local nestedTableRef = resolveReference(“mytable.mynestedtable”);
nestedTableRef = { a: "totally new table };
server.log(resolveReference(“mytable.mynestedtable.a”) //prints “regular table”
nestedTableRef.a = "totally newer table"
server.log(resolveReference(“mytable.mynestedtable.a”) //prints “totally newer table”
`
The function works great for resolving the element at the provided location, so it is great for reading data. It is also great for writing data if and only if the element is a table, and you want to alter the elements in the table itself, but one cannot expect the element to change by just overwriting the return value of the function.
Now all of this can be easily solved without changing the function, but the above code would have to be altered to the following:
`
local tableRef = resolveReference(“mytable”);
tableRef.mystring <- “my new string”; //need to use “<-” in case the nested element doesn’t exist
server.log(resolveReference(“mytable.mystring”) //prints “my new string”
tableRef.mynumber <- 10;
server.log(resolveReference(“mytable.mynumber”) //prints 10
tableRef.mynestedtable <- { a: "totally new table };
server.log(resolveReference(“mytable.mynestedtable.a”) //prints “totally new table”
`
Essentially, one must use the function to traverse to the containing table to alter the elements in place.
Hopefully that was helpful rather than confusing!