syntax question: track an array using variable values
hello everyone ^^
i'm just optimising the dialogs engine in my game, but here's my current problem: for now, i have:
> an array that contains all in-game texts:
Code:
dialog = new Array();
dialog[0] = "hello, my name is...";
dialog[1] = "goodbye, i'm leaving.";
> now, when a popup window appear, the dialog is called in a dynamic text field:
Code:
this.dynamic_text = dialog[1];
> you guessed it, "goodbye, i'm leaving" is the text that appears (my actual engine is a bit more complicated, but the idea is the same).
now
imagine that the previous array is named differently:
Code:
dialog_pox2_poy4 = new Array();
dialog_pox2_poy4[0] = "hello, my name is...";
dialog_pox2_poy4[1] = "goodbye, i'm leaving.";
here are also two variables
my question
how to call the array "dialog_pox2_poy4" using the variables values? (i mean, how to replace "2" and "4" in the array with the variables)...
> example that is not working, but to show you what i mean:
Code:
this.dynamic_text = this["dialog_pox"+popo+"_poy"+pipi+"[1]"];
thanks for your answers
Re: syntax question: track an array using variable values
Code:
this.dynamic_text = this["dialog_pox"+popo+"_poy"+pipi][1];
this should work.
k. ;)