Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Database npcs and objects (https://forums.graalonline.com/forums/showthread.php?t=67058)

KuJi 06-30-2006 06:43 AM

Database npcs and objects
 
V------------------------------------------------------V
gang_Test.rank.leader.Boss.ChiefBoss= "Chief Underboss";
gang_Test.rank.leader.Boss.Underboss= "Underboss";
gang_Test.rank.leader.Boss= "Boss";
gang_Test.rank.leader.Boss.Tester= "Tester";
gang_Test.rank.leader.Boss.Player= "Player";
gang_Takzhe.rank.leader= "KuJi";

^------------------------------------------------------^
The above is in a database npc called Gang Control.

How would I be able to read that gang_Test.rank is an object and everything after it should be added to a object called gtest.

I've tried several things:
One of them would be:
gtest = new TStaticVar();
gtest = this.gang_Test.rank;

With still nothing working, and even after talking to a couple of friends that script I still can't solve it. If you know a way, please post it.

Thanks

ApothiX 07-01-2006 12:13 AM

Your variables seem a bit odd to me.

Quote:

gang_Test.rank.leader.Boss= "Boss";
that one specifically. If you are setting it to a string, it probably should be deleting the object that it was and replacing it with only a string value.

Before you set these variables in the DB-NPC, did you do something like:
PHP Code:

this.gang_Test = new TStaticVar(); 

?

Novo 07-01-2006 12:39 AM

How about this?

PHP Code:

function onCreated()
  {
  
temp.rank createSubObjectgang_Test"rank." );
  }

function 
createSubObjectobjstrPart )
  {
  
temp.oobj = new TStaticVar();
  
temp.vars getObjKeysobjstrPart );
  for ( 
temp.var: temp.vars )
    
makevar"temp.oobj."temp.var ) = makevar"obj.rank."temp.var );
  return 
temp.oobj;
  }

public function 
getObjKeysobjstrNeedle 
  { 
  if ( 
obj.type() != )
    return 
getstringkeysobj );

  
temp.vars obj.savevarstoarrayfalse ); 
  for ( 
temp.var: temp.vars 
    if ( 
temp.var.startsstrNeedle ) ) 
      
temp.keys.addtemp.var.substringstrNeedle.length(), temp.var.pos("=") - strNeedle.length()) );

  return 
temp.keys;
  } 


ApothiX 07-01-2006 01:18 AM

Quote:

Originally Posted by Novo
How about this?

PHP Code:

function onCreated()
  {
  
temp.rank createSubObjectgang_Test"rank." );
  }

function 
createSubObjectobjstrPart )
  {
  
temp.oobj = new TStaticVar();
  
temp.vars getObjKeysobjstrPart );
  for ( 
temp.var: temp.vars )
    
makevar"temp.oobj."temp.var ) = makevar"obj.rank."temp.var );
  return 
temp.oobj;
  }

public function 
getObjKeysobjstrNeedle 
  { 
  if ( 
obj.type() != )
    return 
getstringkeysobj );

  
temp.vars obj.savevarstoarrayfalse ); 
  for ( 
temp.var: temp.vars 
    if ( 
temp.var.startsstrNeedle ) ) 
      
temp.keys.addtemp.var.substringstrNeedle.length(), temp.var.pos("=") - strNeedle.length()) );

  return 
temp.keys;
  } 


w-hat? If you're going to use spaces in your style, atleast be consistant with it. But anyways:

If that 'getObjKeys' function is what I think it is, it's redundant. You can just use this.objectname.getvarnames() to return an array with the list of members in it.

Novo 07-01-2006 01:26 AM

Quote:

Originally Posted by ApothiX
w-hat? If you're going to use spaces in your style, atleast be consistant with it. But anyways:

If that 'getObjKeys' function is what I think it is, it's redundant. You can just use this.objectname.getvarnames() to return an array with the list of members in it.

Hrm... I've experienced problems with getvarnames... I'm not sure what it was... Mayhaps it be the multiple "."'s in a variable? ( obj.var.subvar, obj.getVarNames() only returns obj.var ... )


All times are GMT +2. The time now is 03:54 PM.

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