Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Iter over object members (https://forums.graalonline.com/forums/showthread.php?t=134269197)

JohnnyChimpo 05-08-2014 10:08 PM

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.

fowlplay4 05-08-2014 11:51 PM

post your code?

JohnnyChimpo 05-08-2014 11:53 PM

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.

JohnnyChimpo 05-09-2014 12:36 AM

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));
}


JohnnyChimpo 05-09-2014 12:53 AM

This does not however show member functions that are type object.

BlueMelon 05-09-2014 01:12 AM

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

JohnnyChimpo 05-09-2014 10:29 AM

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!


All times are GMT +2. The time now is 06:26 AM.

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