|
-
DOT-INVADER
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
-
ʞ33ƃ
this.dynamic_text=dialog_pox2_poy4[popo]
like this?
-
DOT-INVADER
oh no, not at all ^^
> change the bold part
this.dynamic_text = dialog_pox2_poy4[1];
> using the variables values popo and pipi
-
ism
Code:
eval("dialog_pox"+popo+"poy"+pipi)[0] = value;
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Senior Member
Blink, didnt you forget "_" infront of "poy"?
eval("dialog_pox"+popo+"_poy"+pipi)[0] = value;
-
ism
i do believe i did
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Re: syntax question: track an array using variable values
Code:
this.dynamic_text = this["dialog_pox"+popo+"_poy"+pipi][1];
this should work.
k.
-
DOT-INVADER
thanks guys, it's working like a charm ^^
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|