TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Hash datatype?

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
zorlac



Joined: 14 Jan 2005
Posts: 18
Location: South America

PostPosted: Thu May 14, 2009 9:29 am    Post subject: Hash datatype? Reply with quote

Hi, I was wondering if its possible to use a directaccess datatype... what for? hmm well suppose I do have a list of enemies atm..suppose its length is 100

and I do wanna check a list of online ppl against it...suppose its 25 length.

Itīd be nice to just have a method hashlike: enemies.contains($whoeveriwannacheck)?
where id only have to check once the datatype against the charname..instead of 25 times loop on the worse scenario for items on the end of the list.

atm I loop through the whole list checking if the name is stored there...but performance wise i think itīd be nice a new datatype Smile just an idea..

or maybe the datatype is already implemented and Im missing it?

Z
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3281

PostPosted: Thu May 14, 2009 9:39 am    Post subject: Reply with quote

Tintin doesn't support associative arrays, but it's possible to use its list support in this case:

Code:

#var enemies {{Bubba} {Bob} {Bilbo}}

#function {listfnd}
{
  #list %1 fnd {%2} result
}

#alias {isenemy}
{
  #if {@listfnd{enemies %0}}
  {
    #showme %0 is an enemy
  }
  {
    #showme %0 is not an enemy
  }
}
Back to top
View user's profile Send private message Send e-mail
zorlac



Joined: 14 Jan 2005
Posts: 18
Location: South America

PostPosted: Thu May 14, 2009 9:47 am    Post subject: Reply with quote

Thanks scandum
Back to top
View user's profile Send private message
zorlac



Joined: 14 Jan 2005
Posts: 18
Location: South America

PostPosted: Tue May 19, 2009 7:01 pm    Post subject: hmm almost working Reply with quote

Heya,

I followed your example and it works for singlewords.. but somehow the fnd command is not working for me on more than 1 word.. any idea what am I doing wrong?
for example:

#var layerstier1 {{toughened leather} {oiled calfskin} {softened hide} {buckskin} {rough shagreen} {embossed leather} {soft suede} {sand-baked hide}}

#if {@listfnd{layerstier1 %0}}
is true for buckskin...but it fails trying to look for other comps.

thanks Smile

Z
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3281

PostPosted: Tue May 19, 2009 10:13 pm    Post subject: Reply with quote

Following ought to do the trick for that: #if {@listfnd{layerstier1 {%0}}}
Back to top
View user's profile Send private message Send e-mail
zorlac



Joined: 14 Jan 2005
Posts: 18
Location: South America

PostPosted: Wed May 20, 2009 12:52 am    Post subject: woot Reply with quote

awesome thanks again! Thumbs Up
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Feature Requests All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group