View Single Post
  #7  
Old 07-05-2009, 11:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by [email protected] View Post
Lovely post, I'd do my selling of the fish differently though

PHP Code:
temp.fish = {
  
"Salmon"10,
  
"Trout"15,
  
"Yada"5
};

temp.saleamount temp.fish.index( (selling fish name heresent from the triggeraction) ) + 1
The code you posted is wrong, actually. You'd need to do this (you forgot to take that index out of the array):

PHP Code:
temp.saleamount temp.fish[temp.fish.index(fish) + 1]; 
My way is probably more efficient, however, since the engine isn't having to check through the array once to find the index, add one to the index, then loop through the array again to find the other index. However, it'd be such a miniscule difference it would work fine either way.
__________________
Reply With Quote