PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
.name on Realms()

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
Repsak



Joined: 05 Feb 2006
Posts: 91
Location: Denmark

PostPosted: Tue Aug 01, 2006 5:49 am    Post subject: .name on Realms() Reply with quote

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)

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 355
Location: San Diego, California

PostPosted: Tue Aug 01, 2006 7:39 am    Post subject: Reply with quote

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)

Author Message
Repsak



Joined: 05 Feb 2006
Posts: 91
Location: Denmark

PostPosted: Wed Aug 02, 2006 5:47 am    Post subject: Reply with quote

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/objref.php#Dictionary.

Thanks for your help Smile

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 355
Location: San Diego, California

PostPosted: Wed Aug 02, 2006 6:42 am    Post subject: Reply with quote

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.

Author Message
Lagoon



Joined: 05 Mar 2006
Posts: 118
Location: Italy

PostPosted: Fri Aug 04, 2006 7:08 am    Post subject: Reply with quote

Damn, I misse dthis too -___-''
I'll use it from now on, it's very handy Smile

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 355
Location: San Diego, California

PostPosted: Fri Aug 04, 2006 7:16 am    Post subject: Reply with quote

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

Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty