Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Objects ... (https://forums.graalonline.com/forums/showthread.php?t=72578)

cbk1994 03-04-2007 01:50 AM

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)

Skyld 03-04-2007 01:57 AM

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".

cbk1994 03-04-2007 03:18 AM

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

Chandler 03-04-2007 11:04 AM

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! ;)"


cbk1994 03-04-2007 03:21 PM

Quote:

Originally Posted by Chandler (Post 1284497)
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.

Chandler 03-04-2007 06:44 PM

Quote:

Originally Posted by cbkbud (Post 1284537)
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 :p

Admins 03-04-2007 07:26 PM

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.

cbk1994 03-04-2007 08:03 PM

Skyld came on and fixed my code.
<3 Skyld


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

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