Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   [Help] Clearing a ton of arrays (https://forums.graalonline.com/forums/showthread.php?t=82282)

DarkReaper0 10-11-2008 11:47 PM

[Help] Clearing a ton of arrays
 
Edit: Resolved


Right so, I'm having an issue.
Each time a player touches an NPC specified for dialogue it loads a text file, first resets the variables, organizes it all, then displays it in the checkbox text.

My only problem is that after i talk to one NPC and go up to another, it doesn't seem to reset, and if the new NPC has blank options where the first NPC actually had something written, it shows the data from the first npc's variables....

I only posted snippets for convenience (for you and me).

PHP Code:

//Portion that supposedly resets all the variables
for(temp.y=1;temp.y<=5;temp.y++) {
  
temp.file=
{
"choice"@i@"options","choice"@i@"sub"@i@"options","choice"@i@"sub"@i@"sub"@i@"options",
        
"choice"@i@"sub"@i@"sub"@i@"sub"@i@"options","choice"@i@"sub"@i@"sub"@i@"sub"@i@"sub"@i@"options"};
  for(
temp.q=0;temp.q<5;temp.q++) {
    
this.("file"@lowercase(temp.file[q])).clear();
    echo(
"Array:" SPC this.("file"@lowercase(temp.file[q])));
  }
}
//******************//

//Portion that organizes all the data into the variables (This part works)
function OrganizeData() {
  for (
temp.i=0;temp.i<this.file.size();temp.i++) {
    if (
this.file[temp.i].starts("CHOICE")) { //Stuff like "CHOICE1SUB2SUB1OPTIONS"
      
temp.s=temp.i+1;
      while(!
this.file[temp.s].starts("ENDCHOICE"))
      {
       
this.("file"@lowercase(this.file[temp.i])).add(this.file[temp.s]);
       
temp.s+=1;
      }
    }
  }
}
//********************//

//Where all the information is used

this.speechplacement@="sub"@input//input would be "sub2sub1" or "sub2sub1sub1" and etc.

if (temp.t.size()>0dialogue_CheckBox1.text=this.("file"@this.speechplacement@"options")[0];
if (
temp.t.size()>1dialogue_CheckBox2.text=this.("file"@this.speechplacement@"options")[1];
if (
temp.t.size()>2dialogue_CheckBox3.text=this.("file"@this.speechplacement@"options")[2];
if (
temp.t.size()>3dialogue_CheckBox4.text=this.("file"@this.speechplacement@"options")[3];
if (
temp.t.size()>4dialogue_CheckBox5.text=this.("file"@this.speechplacement@"options")[4];
//****************// 

All help is appreciated, I'm sorry if the styling hurts your eye's.

If anything is unclear or I left something out just ask for it.

xXziroXx 10-11-2008 11:52 PM

Wouldn't it be smoother to load all data upon creation rather then when touched?

DarkReaper0 10-11-2008 11:54 PM

It loads different files depending on which npc you go up to and touch.

I don't think on creation would work out so hot.

Edit: When you touch an NPC it's joined to a class which in turn sends a triggerserver() to this weapon script which then loads the corresponding text file.

xXziroXx 10-12-2008 12:00 AM

Well, I'm having problems understanding your script due to the styling, it totally doesn't flow well with me... but that's a personal preference, but alas, it's not allowing me to be of much help.

I don't know, but couldn't you run a getStringKeys() loop on the NPC's this. variables and set them to blank? Should definitely clear them.

DarkReaper0 10-12-2008 12:05 AM

Quote:

Originally Posted by xXziroXx (Post 1431939)
I don't know, but couldn't you run a getStringKeys() loop on the NPC's this. variables and set them to blank? Should definitely clear them.


Odam I totally forgot about that.

Thanks.


All times are GMT +2. The time now is 12:00 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.