playMaker

Author Topic: Increment String value on each click  (Read 916 times)

Rajeev

  • Playmaker Newbie
  • *
  • Posts: 8
Increment String value on each click
« on: July 28, 2021, 02:41:50 AM »
Hello,
I have an FSM Array of 20 string variables with each holding the Name of a Global Event as its value. I need to get the value at index 0 on the first button click and use it to send the Event to another FSM. The second click on that button should get the value at index 1, the third click from index 3 and so on till all the variables in the FSM array are over.
I would be very grateful if anybody could help me achieve this using Playmaker.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Increment String value on each click
« Reply #1 on: July 28, 2021, 05:26:59 AM »
Hi.
You can use a Array Get Next to loop thru the array.

Here a video that might help :

Rajeev

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Increment String value on each click
« Reply #2 on: July 28, 2021, 07:52:33 AM »
Hello djaydino,

Thanks for the advise and the video. I'll try to implement my requirement using Array Get Next and get back to you if I succeed, or not. Thanks.

Regards

Rajeev

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Increment String value on each click
« Reply #3 on: July 30, 2021, 12:36:34 PM »
Hello djaydino Sir,

Thank you very much for pointing me towards the Array Get Next action. It took some time in replying since I wanted to implement the action in my FSM requirement and check that it fully worked and achieved what I needed. Glad to inform that it works like a charm and has helped me a lot.

I ran into one issue during the trial. There is a scenario in my project where a user can start a new Play and the Array Get Next action would have to reiterate from start. I was unable to get the Reset Flag function of the action work properly no matter what I tried.
I was ready to run back here and shout for help, but thought of searching the forum to check if anybody else faced the same problem, and I came across the Array Get Next 2 action on the EcoSystem. This action has solved my requirement completely. So, thank you very much once again.

I am now setting the Reset Flag to true in the FSM that runs when on click of the "New Play" button, and have set a state with the 'Set Bool value" Math action just after the state holding the Array Get Next 2 action to reset the bool. This does the job but doesn't seem right since the bool is reset unnecessarily about 20 times without serving any purpose.

I thought of using the Simple Loop Counter action to run the state once, but it seems like an overkill just to reset one bool. Could you please advise me on how to go about this correctly?

Thanks and Warm Regards

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Increment String value on each click
« Reply #4 on: July 30, 2021, 02:53:22 PM »
Hi.
The Reset Flag should be set true before the loop, else it will always get the first index if its done within the loop.

Maybe you can show your setup (some pictures or short video)