It is currently Mon Dec 01, 2008 12:44 pm

All times are UTC - 8 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: .name on Realms()
PostPosted: Tue Aug 01, 2006 1:49 am 
Offline

Joined: Sun Feb 05, 2006 2:00 am
Posts: 91
Location: Denmark
How about adding .name to the struct returned by Realms()?
How else would you get the realm name if you have to loop through all the realms, looking for something? (Well besides from a escript function, with a case on mapid, but that is not a nice solution)

_________________
When was the last time, you did something for the first time?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 3:39 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 430
Location: San Diego, California
Just .. give this a try (trust me)

Code:
use uo;
use polsys;

Program ShowMeTheRealms()
       foreach realm in ( Realms() )
             Print("I am on realm ->"+_realm_iter);
             SleepMS(2);
       endforeach
       
       return 1;
endprogram


Remember that Realms() returns a dictionary.
The key is the realm name. You could also use ( Realms.Keys() ) to only get the realm names. If you iterate Realms() directly though, the pointer becomes the key name. In an array it would be an integer. _(var)_iter is a bonus variable in foreach loops (since 095)

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 1:47 am 
Offline

Joined: Sun Feb 05, 2006 2:00 am
Posts: 91
Location: Denmark
I have been running a shard since pol92 singlehanded, worked with Dict, struct in EScript. I have worked with iterators in C++, yet I would have never found out that myself, and I dont remember seeing any documentation or core changes for that.
Maybe add a few words about this in the documentations for Dictionary, in http://poldoc.fem.tu-ilmenau.de/pol096/ ... Dictionary.

Thanks for your help :)

_________________
When was the last time, you did something for the first time?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 2:42 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 430
Location: San Diego, California
Yeah its very obscure. I found out about it in core-changes.txt when 095 was released. Prior to that it was called _(var)_counter and was never documented.

It has recently been put into Racalac's script guide for 096 on POL-Doc.

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 3:08 am 
Offline

Joined: Sun Mar 05, 2006 7:25 am
Posts: 118
Location: Italy
Damn, I misse dthis too -___-''
I'll use it from now on, it's very handy :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 3:16 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 430
Location: San Diego, California
Better elaborations...

The variables:

var alpha := dictionary{"a"->1, "b"->2, "c"->3};
var bravo := array{"a", "b", "c"};

Code:
foreach key in ( alpha.Keys() )
     Print(_key_iter+"=="+key);
endforeach

Result:
1==a
2==b
3==c


Code:
foreach value in ( alpha )
     Print(_value_iter+"=="+value);
endforeach

Result:
a==1
b==2
c==3


Code:
foreach value in ( bravo )
     Print(_value_iter+"=="+value);
endforeach

Result:
1==a
2==b
3==c

_________________
-Austin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl