Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-11-2008, 11:47 PM
DarkReaper0 DarkReaper0 is offline
No.
DarkReaper0's Avatar
Join Date: May 2005
Location: Texas,USA
Posts: 344
DarkReaper0 will become famous soon enough
Send a message via MSN to DarkReaper0
[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.

Last edited by DarkReaper0; 10-12-2008 at 12:14 AM.. Reason: Issue resolved
Reply With Quote
  #2  
Old 10-11-2008, 11:52 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Wouldn't it be smoother to load all data upon creation rather then when touched?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #3  
Old 10-11-2008, 11:54 PM
DarkReaper0 DarkReaper0 is offline
No.
DarkReaper0's Avatar
Join Date: May 2005
Location: Texas,USA
Posts: 344
DarkReaper0 will become famous soon enough
Send a message via MSN to DarkReaper0
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.

Last edited by DarkReaper0; 10-11-2008 at 11:57 PM.. Reason: Clarification
Reply With Quote
  #4  
Old 10-12-2008, 12:00 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 10-12-2008, 12:05 AM
DarkReaper0 DarkReaper0 is offline
No.
DarkReaper0's Avatar
Join Date: May 2005
Location: Texas,USA
Posts: 344
DarkReaper0 will become famous soon enough
Send a message via MSN to DarkReaper0
Quote:
Originally Posted by xXziroXx View Post
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:02 PM.


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