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 05-08-2014, 10:08 PM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
Iter over object members

I currently cant find a resolution to be able to loop over members of an object. Is there a solution for this? I am using a TStaticVar object.
Reply With Quote
  #2  
Old 05-08-2014, 11:51 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
post your code?
__________________
Quote:
Reply With Quote
  #3  
Old 05-08-2014, 11:53 PM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
I was just trying for ( item : object ), I mean i have no code per-say, i was just trying to iterate through members of the object. I basically want to check to see which type they are and do something based on the outcome.
Reply With Quote
  #4  
Old 05-09-2014, 12:36 AM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
For all of you that dont know, here is the code. I guess i had to just step away from it, and also read through the scriptfunctions_client.txt which is terrible to look at.

Well.... ugly but thats gs2

NPC Code:

temp.obj = new TStaticVar("obj");
temp.obj.name1 = "steve";
temp.obj.number = 123;
temp.obj.float1 = 1.23;
temp.obj.strarray = { "asdf", "adsf", "adfdfgsd" };
temp.obj.numarray = {1,2,3};
temp.obj.botharray = {1,2,"asdfdsf"};
temp.obj.obj1 = new TStaticVar("sfg");
temp.obj.obj1.ha = "yea";
temp.obj.obj1.paws = true;
temp.list = temp.obj.getdynamicvarnames();

for ( temp.item : temp.list ){
echo(temp.obj.(@temp.item).type());
echo (temp.obj.(@temp.item));
}

Reply With Quote
  #5  
Old 05-09-2014, 12:53 AM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
This does not however show member functions that are type object.
Reply With Quote
  #6  
Old 05-09-2014, 01:12 AM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
PHP Code:
pecho(temp.item SPC temp.obj.(@temp.itemSPC temp.obj.(@temp.item).type() SPC temp.obj.(@temp.item).objecttype() ); 
Changed your echo to this and got
PHP Code:
botharray 1,2,asdfdsf 3 TGraalVar
float1 1.23 0 TGraalVar
name1 steve 1 TGraalVar
numarray 1
,2,3 3 TGraalVar
number 123 0 TGraalVar
obj1 sfg 2 TStaticVar
strarray asdf
,adsf,adfdfgsd 3 TGraalVar 
Not exactly sure what you are expecting as output
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #7  
Old 05-09-2014, 10:29 AM
JohnnyChimpo JohnnyChimpo is offline
Registered User
JohnnyChimpo's Avatar
Join Date: Jun 2004
Posts: 105
JohnnyChimpo is on a distinguished road
I guess I was mistaken it seems to show objects for you. And I'm not concerned about how pretty the output is just the functionality . Thanks for your help!
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 10:57 PM.


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