Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-30-2006, 06:43 AM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
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
Reply With Quote
  #2  
Old 07-01-2006, 12:13 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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(); 
?
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #3  
Old 07-01-2006, 12:39 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
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;
  } 
Reply With Quote
  #4  
Old 07-01-2006, 01:18 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 07-01-2006, 01:26 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
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 ... )
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 07:47 PM.


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