Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-04-2007, 01:50 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Objects ...

Basicly, I do
this.messages.cbk1994 = { "blah", "blah2", "blah3" };
then I have this.messages.cbk1994.blah = "variable here";
then
echo( this.messages.cbk1994.blah );

Nothing echoes. What am I doing wrong? (Yes I suck at objects :C)
__________________
Reply With Quote
  #2  
Old 03-04-2007, 01:57 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Right, in this case, "blah" is part 0 of the array, "blah2" is part 1 of the array, etc. Therefore, to overwrite "blah", you do this.messages.cbk1994[0] = "new value", and likewise to overwrite "blah3", this.messages.cbk1993[2] = "new value".
__________________
Skyld
Reply With Quote
  #3  
Old 03-04-2007, 03:18 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
function onCreated()
{
this.messages.loadVars( this.lasts );
findPlayer( "cbk1994" ).chat = this.messages.cbk1994;
}
basically what happens. I use a script to remove all variables of this.messages. It loads the variables correctly. (In DB-NPC flags it shows them correctly). The variable this.messages.cbk1994 should have a value, but it sets my chat to '0'.
-EDIT-
Apparently the problem is that it is an array ... if I change the array to a string it works fine ... why won't the array work, how can I get it to? Thanks.

-EDIT AGAIN-
I can't
this.messages.cbk1994 = "";
this.messages.cbk1994.clear();

How can I erase it? It is equal to ...
messages.cbk1994=s_cbk1994_20,

direct from the DB NPC
__________________

Last edited by cbk1994; 03-04-2007 at 03:51 AM..
Reply With Quote
  #4  
Old 03-04-2007, 11:04 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
I don't see why you'd want to use loadvars in this scenario.
HTML Code:
public function onretrieveMessages(playerAccount)
  {
  temp.allAccounts = getstringkeys("this.msg_");
  for (temp.currentAccount: temp.allAccounts)
    if (temp.currentAccount == temp.playerAccount)
      temp.messageList = this.(@"msg_"@ temp.playerAccount);
  return(temp.messageList);
  } 
  //You'd call this part of the code, eg "temp.myMessages = this.retrieveMessages(player.account);"
The flags:
HTML Code:
msg_Chandler="Hiya, how're you?", "Today I have a message"
msg_David="I am St...Dave", "hi Chandler! ;)"
Reply With Quote
  #5  
Old 03-04-2007, 03:21 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Chandler View Post
I don't see why you'd want to use loadvars in this scenario.
HTML Code:
public function onretrieveMessages(playerAccount)
  {
  temp.allAccounts = getstringkeys("this.msg_");
  for (temp.currentAccount: temp.allAccounts)
    if (temp.currentAccount == temp.playerAccount)
      temp.messageList = this.(@"msg_"@ temp.playerAccount);
  return(temp.messageList);
  } 
  //You'd call this part of the code, eg "temp.myMessages = this.retrieveMessages(player.account);"
The flags:
HTML Code:
msg_Chandler="Hiya, how're you?", "Today I have a message"
msg_David="I am St...Dave", "hi Chandler! ;)"
I did that before, and it worked except that the DB NPC deleted strings, as they commonly do.
__________________
Reply With Quote
  #6  
Old 03-04-2007, 06:44 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by cbkbud View Post
I did that before, and it worked except that the DB NPC deleted strings, as they commonly do.
They only delete things if you tell it to
Reply With Quote
  #7  
Old 03-04-2007, 07:26 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
I have added a few days ago a new function for deleting sub-variables: obj.clearVars(). It is not uploaded to all machines yet though.
Reply With Quote
  #8  
Old 03-04-2007, 08:03 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Skyld came on and fixed my code.
<3 Skyld
__________________
Reply With Quote
Reply


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 11:58 AM.


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