| View previous topic :: View next topic |
| Author |
Message |
zorlac
Joined: 14 Jan 2005 Posts: 18 Location: South America
|
Posted: Thu May 14, 2009 9:29 am Post subject: Hash datatype? |
|
|
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 just an idea..
or maybe the datatype is already implemented and Im missing it?
Z |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
Posted: Thu May 14, 2009 9:39 am Post subject: |
|
|
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 |
|
 |
zorlac
Joined: 14 Jan 2005 Posts: 18 Location: South America
|
Posted: Thu May 14, 2009 9:47 am Post subject: |
|
|
| Thanks scandum |
|
| Back to top |
|
 |
zorlac
Joined: 14 Jan 2005 Posts: 18 Location: South America
|
Posted: Tue May 19, 2009 7:01 pm Post subject: hmm almost working |
|
|
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
Z |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
Posted: Tue May 19, 2009 10:13 pm Post subject: |
|
|
| Following ought to do the trick for that: #if {@listfnd{layerstier1 {%0}}} |
|
| Back to top |
|
 |
zorlac
Joined: 14 Jan 2005 Posts: 18 Location: South America
|
Posted: Wed May 20, 2009 12:52 am Post subject: woot |
|
|
awesome thanks again!  |
|
| Back to top |
|
 |
|