The Daily Click ::. Forums ::. Klik Coding Help ::. List Object question
 

Post Reply  Post Oekaki 
 

Posted By Message

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
15th March, 2011 at 09:37:10 -

Hello,

I'm using the LIST OBJECT for a weapon inventory system.
Mainly because when you delete a line there isn't a gap. Does that make sense? It doesn't matter!

ANYWAY! Is it possible to search the list for a string and then retrieve the number of that line.

Example:
SHOTGUN
KNIFE
HANDGUN
CROW BAR

Can I search for the a line "HANDGUN" and retrieve that it is at slot "3" in the list?

Thank you everybody for being so helpful!
PEACE XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
15th March, 2011 at 09:46:38 -


Actually I just figured it out.

FindString( "weapon_list", "Handgun", 1)

I'm not sure what changing the 1 does though.
Thanks anyway!



 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
15th March, 2011 at 12:12:18 -

1 is the number of the line to start searching at. I set mine at 0, but I think that that's the same thing as 1. You should use "FindStringExact" instead of just FindString, or you'll get partial matches as well, such as "Handgun" will match against "Handgunammo" in your list.

Lists are pretty powerful once you've gotten used to them hey?

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
15th March, 2011 at 13:42:11 -

Yeah the List Object is amazing!

And thanks! I didn't know the different between FindString and FindStringExact either.
Luckily in this case it doesn't matter because I have separate lists for storing weapons and items.
Handgun is a weapon and HandgunAmmo is an item. But I'll keep it in mind for the future.

Thanks again!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click