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 03-04-2007, 05:19 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Objects in player.attr?

Is there any reason why objects cant be stored in player.attr?

For example using my associative array class

PHP Code:
test = new TStaticVar();
test.join("assocarray");
test.make({"a","b","c"},{"one","two","three"}); 

  
player.attr[8] = test;
  
player.chat player.attr[8].item("a"); 
Doesn't work.

or

PHP Code:
player.attr[8]= new TStaticVar();
player.attr[8].join("assocarray");
player.attr[8].make({"a","b","c"},{"one","two","three"}); 
  
player.chat player.attr[8].item("a"); 
Also doesnt work.

Replacing player.attr[8] with a standard var name there works fine.

Is there any reason objects cant be stored in player.attr?


What i'm trying to do is work out how I can store objects between logins.

I want to make objects persistent. I can't store them in clientr.


The only way I think I can do it is storing the objects in a DB NPC with the player account. However, this seems kinda wasteful because the info on the player would be in memory in the DB NPC when the player is not even online.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #2  
Old 03-04-2007, 05:20 PM
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
I think attr[]s are only capable holding strings.
__________________
Skyld
Reply With Quote
  #3  
Old 03-04-2007, 05:38 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Is there any way to store objects between logins then?


I could serialise the object but I intend to have a tree like structure of objects (in proper OO fashion) so going through each object and storing all the value would be kinda annoying.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #4  
Old 03-04-2007, 07:29 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
attr[] are built-in attributes which can only store strings, right. The engine is currently not serializing objects automatically. You have functions like savevarstoarray(sort), but it's not saving object links or recursive stuff.
Reply With Quote
  #5  
Old 03-04-2007, 07:48 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by Stefan View Post
attr[] are built-in attributes which can only store strings, right. The engine is currently not serializing objects automatically. You have functions like savevarstoarray(sort), but it's not saving object links or recursive stuff.
Would you mind changing player.attr so that it doesn't just support strings?
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 01:27 AM.


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