Right now I can only get my answers displayed when I have an item which was asked for in the dialog. I know that sucks, and I know what I’m doing wrong (wrong position in the hierarchy). I’m actually really tired right now and it was time to go to bed a couple of hours ago so maybe I’m just missing something. Anyway, can anybody have a look at my code and tell me how to do the hierarchy so that I can get my answers to display even if there is no request for an item? I hope I made it a bit clear cause I’m not thinking clear at all right now, sorry.
EDIT: This is just a raw setup to find out how a build a dialog system.
texts = [
["Do you have some (ITEM_RUM) for me?",
"(N)No I don't actually.",
"(N)No, the I drank it all! *Hickup*",
"(Y)Yeah, sure I do!"],
["Your mother is so fat... bla bla!",
"(Y)Ah, shut up!"]
];
var Dialog:Number = 0;
var Text:String = texts[Dialog][0];
var Woord:Array = Text.split(" ");
ITEMS = [
["ITEM_RUM","RUM", "TRUE"],
["ITEM_MAP_TREASURE","TREASURE MAP", "FALSE"]
];
var strippedItem:String;
for (i=0; i<texts[0][0].length; i++) {
if (Woord*.charAt(0) == "(" && Woord*.charAt(Woord*.length-1) == ")") {
strippedItem = Woord*.substr(1,Woord*.length-2);
for(a=0; a<ITEMS.length; a++) {
if (strippedItem == ITEMS[a][0] && ITEMS[a][2] == "TRUE") {
for(b=1; b<texts[Dialog].length; b++) {
if (texts[Dialog]**.substr(0,3) !== "(N)") {
this.answer.text = texts[Dialog]**.substr(3,texts[Dialog]**.length);
}
}
}
}
}
}