playMaker

Author Topic: Get Index ArrayList question  (Read 3875 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 296
    • View Profile
Get Index ArrayList question
« on: August 10, 2012, 01:52:06 PM »
More Array questions!  (But only because they're supremely useful and have changed my life for the better!)

I have a string variable in my FSM.
The same string is contained somewhere in an ArrayList.
I want to find the index that contains the string, so I can store the index in it's own Int variable.

I thought to use Array List Index Of, however I don't know where I declare where to store the Index value once I get it. 

How can I do this?


Thank you!
« Last Edit: August 10, 2012, 02:13:22 PM by artician »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14014
  • Official Playmaker Support
    • View Profile
Re: Get Index ArrayList question
« Reply #1 on: August 13, 2012, 12:47:55 AM »
Hi,


indexOf has a property called "indexOf" this is where you should  select the fsm int that you want to store the index of the item you'll find in that array.

if you are still strugglin, I'll do a working example.

bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 296
    • View Profile
Re: Get Index ArrayList question
« Reply #2 on: August 13, 2012, 10:32:48 AM »
This is the "Index Of" within the "setup" portion of the action, correct?

I wasn't certain that this was the correct field since it was in the setup area.  Let me know if that's what you mean.

Thank you!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14014
  • Official Playmaker Support
    • View Profile
Re: Get Index ArrayList question
« Reply #3 on: August 13, 2012, 11:51:05 PM »
Hi,

 yes, It could have been laid out better, I agree, but yes, that's the "index Of" field you need.

bye,

 Jean

Netjera

  • Playmaker Newbie
  • *
  • Posts: 41
    • View Profile
Re: Get Index ArrayList question
« Reply #4 on: August 31, 2012, 10:30:59 PM »
I'm so glad I found this!  I was having the same problem.  Okay, so "index of" is the integer variable to store the index value.  If I set a GameObject in the data section, that's what it will look for in the array, and it will store the index of that object in the index of variable?

Thanks!  I've been playing around with this for a couple of days, trying to get a basic card setup working, specifically so I could learn how it works.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14014
  • Official Playmaker Support
    • View Profile
Re: Get Index ArrayList question
« Reply #5 on: September 03, 2012, 01:27:01 AM »
Hi,

 Yes, but very important, DO NOT FORGET to set the "Fsm variable Type" property to the one you expect, so if you want to check the index of a "string", you have to set "Fsm Variable type" to "Fsm String" AND fill the "Set String Data" property as well with the value you want to check it against.

 bye,

 Jean

joviermark

  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
Re: Get Index ArrayList question
« Reply #6 on: November 22, 2012, 11:17:12 PM »
More Array questions!  (But only because they're supremely useful and have changed my life for the better!)

I have a string variable in my FSM.
The same string is contained somewhere in an ArrayList.
I want to find the index that contains the string, so I can store the index in it's own Int variable.

I thought to use Array List Index Of, however I don't know where I declare where to store the Index value once I get it. 

How can I do this?


Thank you!


If your want to store string with index better use Hashtable


http://csharp.net-informations.com/collection/csharp-hashtable.htm

Hope it willhelp you.

Jov.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14014
  • Official Playmaker Support
    • View Profile
Re: Get Index ArrayList question
« Reply #7 on: November 23, 2012, 12:10:38 AM »
Hi,

 ArrayMaker also supports Hash tables actually ( I know I should have come up with a better name...)


I think however that what Artician was after is indeed using an array of string and get the index of that string within the array. As opposed to use string based indexing to reference strings.

with array:
0-> "my string"
1-> "my second string"
2-> "my third string"

with Hashtable:
"whatever key" ->"my string"
"your own key" ->"my second string"
"one last key"   ->"my third string"

bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 296
    • View Profile
Re: Get Index ArrayList question
« Reply #8 on: November 24, 2012, 11:27:51 AM »
Yeah Jean has it right.  That's what I was after.

Jean - Have you ever gotten something working for saving an Array/HashTable?  Just curious!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14014
  • Official Playmaker Support
    • View Profile
Re: Get Index ArrayList question
« Reply #9 on: November 24, 2012, 12:33:29 PM »
Hi,

 not yet, you can really save my proxies conveniently currently. It's a common request that I ought to implement on the next version, that btw will be a lot easier to work with as the next version of playmaker will feature new action fields  that will simply let you select first a fsm variable type and then select that variable, so the actions will be down to a more digestable size and a lot less scary and inefficient and prone to error and frustration.

bye,

 Jean