I have dialog in a javascript object separated into objects and arrays (similar to JSON format).
I'd like to access these objects and arrays by passing in their respective variable names...
For example, how would I access the "parent_object_name" object and child array "array_name"? I've tried creating objects and arrays, then passing them in, as such:
var parent_object_name = npc_dialog.people[NPC_id].dialogs.answers;
var child_array_name = npc_dialog.people[NPC_id].dialogs.answers.AnswerOne;
cycleDialog(0, parent_object_name, child_array_name);
But that didn't work...
So then I tried passing the names in as strings:
cycleDialog(0, "parent_object_name", "child_array_name");
This also didn't work.
cycleDialog takes those variables and substitutes them in as such:
function cycleDialog(NPC_id, TYPE, SUBTYPE) {
NPCs_ARRAY[NPC_id].children[1].text = npc_dialog.people[NPC_id].dialogs.TYPE.SUBTYPE[dialog_id];
}
Thank you
EDIT:
Data looks like:
"dialog" :
{
"dialog_name" :
[
"dialog",
"more text..."
]
},
"answers" :
{
"answer_name" :
[
"answer text here",
"more text..."
]
}