View Single Post
  #10  
Old 05-14-2008, 04:52 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by DustyPorViva View Post
Zero: Yours confuses me I'll have to go over it after I go to bed.
Basically, the has function just takes the text (be it a gui name or so) and returns some sort of number. A very SIMPLE example of a hash function might be:

PHP Code:
function hash(i) return i%10
Of course, that is designed for integers, not strings. It's a programming technique designed mostly for creating hash tables that are used in sorting and such but I think it would work pretty well in this situation.

EDIT: Here's a simpler alternative if you don't want to deal with hashing:
In the onCreated of a "Main"-like system wnpc, put:
PHP Code:
global = new TStaticVar("_");
global.
join("globalfunctions"); 
Then in the globalfunctions class:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.showimgtable = {
    
"hearts",
    
"fullhearts",
    
"arrows"
  
};
}

function 
getImgIndex(text) return 201 this.showimgtable.index(text); // If index is -1, then it will return 200

function getImg(textobjwith (obj) return findimg(getImgIndex(text)); 
Now it's easy to showimgs:

PHP Code:
showimg(_.getImgIndex("hearts"), "heart.png"204405);
_.getImg("fullhearts"this).image "fullhearts"
Make sense?
__________________
Do it with a DON!

Last edited by zokemon; 05-14-2008 at 05:02 PM..
Reply With Quote