playMaker

Author Topic: Array List Get Next not resetting?  (Read 9770 times)

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Array List Get Next not resetting?
« on: May 12, 2014, 04:57:04 PM »
Hi,
I'm using an ArrayListGetNext action to loop through some things in an array and then using the Finished event to do something else.

This is all working fine, but the trouble is that if I go back to that same action later and use that same ArrayListGetNext again, the second time it just goes straight to the Finished event instead of starting at the beginning again. it's like it's not resetting to the beginning of the list or something, but instead just leaving the pointer at the end where it left off previously.

Is anyone else having this problem, or do I need to do something different?

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Array List Get Next not resetting?
« Reply #1 on: May 13, 2014, 03:39:59 AM »
I have been using the Array List Get Next action a lot recently and I havent seen this kind of problem. I have even made a test to see if the action would loop infinitly and it does.
Maybe your array list got empty ?
Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array List Get Next not resetting?
« Reply #2 on: May 13, 2014, 07:23:53 AM »
Hi,

 there is indeed a problem, I need to over all of these getnext xxx and insert a boolean variable to force a reset as you renter the state if you haven't fully processed all items in the loop.

 Coming soon :)

Bye,

 Jean

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Array List Get Next not resetting?
« Reply #3 on: May 21, 2014, 12:04:53 PM »
I don't mean to rush you because I'm sure you have a lot going on, but any progress on this?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array List Get Next not resetting?
« Reply #4 on: May 21, 2014, 03:45:34 PM »
Hi,

 Yes, it's already solved in my local version, I need to push it to the wiki sometime this week.

I referenced it on the trello task, and now it's ticked :)

https://trello.com/c/FamlVQBD/31-arraymaker-update

 Thanks for your patience :)

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array List Get Next not resetting?
« Reply #5 on: May 23, 2014, 07:36:59 AM »
Hi,

 ok, it's up now, download from the wiki again. Let me know how it goes.

bye,

 Jean

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Array List Get Next not resetting?
« Reply #6 on: May 23, 2014, 12:47:02 PM »
So where exactly would that be? I'm not seeing anything on your wiki page.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array List Get Next not resetting?
« Reply #7 on: May 27, 2014, 07:16:24 AM »
Hi,

  I mean download ArrayMaker again here:

https://hutonggames.fogbugz.com/default.asp?W715

Bye,

 Jean

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Array List Get Next not resetting?
« Reply #8 on: May 27, 2014, 12:37:11 PM »
Okay, so I re-downloaded and installed Arraymaker, but either I'm confused or it's not working.

In the ArrayListGetNext action I know see the "Reset" item. The tooltip says "Set to true to force iterating from the first item". The trouble is, there is no true or false to set. There is only "None" and "Proceed".

Choosing None doesn't do anything. Choosing Proceed adds a readout box that says "False" by default, but again, no way of setting anything to true.

With either setting it still runs the same as before.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array List Get Next not resetting?
« Reply #9 on: May 29, 2014, 12:52:20 AM »
Hi,

create a "reset loop" boolean variable, and have a state prior entering this looping state where you set this "reset loop" to true. then the "next" action will use that reset loop, check if it's true, if it force starting index to be 0, and set that "reset loop" to false.

 so everytime you know you exited early a loop, set that "reset loop" to true to make sure it gets reseted next time you enter the loop.

Bye,

 Jean

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Array List Get Next not resetting?
« Reply #10 on: May 30, 2014, 07:27:16 AM »
Did it work? The same thing seems to happen with get next child... I resorted to using get random for both array and child.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Array List Get Next not resetting?
« Reply #11 on: May 31, 2014, 01:51:28 AM »
Unfortunately, I'm still having no luck. Though I'm guessing it's something I'm doing. In the attachment you can see the test setup I did. The Idle state at the beginning is just a gui button to start to sequence. "draw gui text field" just makes a text input box and stores the input in the string "letterFromInput" (which you don't see in this shot).

Once the player inputs text (in this case I just do a single letter), it goes on to ArrayListSearch. The object contains an array of 26 entries, the alphabet. Array List Get Next is supposed to step through each of those entries, passing the current entry on to the "CheckLetter" state, which just compares the string entry in the array to the letter I input at the beginning. If the strings match, it displays them, if not, it goes back to the ArrayListSearch, which should step to the next array list entry.

Unfortunately, with the settings shown here, it never does find the right entry. It just loops until I get the "looped 1000 times" error.

I assume I'm still doing something wrong, but I don't understand what. I was hoping from the original reply from Jean that "insert a Boolean value" meant there would be some kind of checkbox that said something like "always start from first entry" or something like that. I know that sounds lazy, but due to the confusing nature of this setup, it would help make it "idiot-proof" to idiots like me ;D

Anyway, I get that the problem is probably that every single time it iterates, the Reset Boolean gets set back to true, so it never gets past the first entry, but I'm not understanding how to set it up to separate that step. A small working example of this setup would go a long way to help figuring this out.
« Last Edit: May 31, 2014, 01:53:30 AM by Gevarre »

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Array List Get Next not resetting?
« Reply #12 on: May 31, 2014, 11:24:15 PM »
Okay, so I got it figured out and working, at least for ArrayListGetNext. I don't know about the others. It came down to me not thinking correctly on how logic moved between actions. The way I had it, the "reset" variable was set to true in the same state as the ArrayListGetNext action. I was picturing that when it looped back in to check the next entry in the array, it would just go straight to ArrayListGetNext, which, of course, now that I look at it again, it doesn't do. The flow always goes back to the first action in the stack even if an action in the stack is set to some sort of "loop". The way I had it resulted in ArrayListGetNext ALWAYS restarting with the first entry and never getting past it.

So here's the correct way to set it up (This is specifically for ArrayListGetNext. I assume others work similarly):

1. Create a Boolean. I called mine "resetMyArray". Set the default to false.
2. Create a state that contains the ArrayListGetNext action.
3. In the drop-down box to the right of "Reset" select "resetMyArray" or whatever you named your Boolean to.

So now whenever that state is first ENTERED, and "resetMyArray" is true, it will start looping from the beginning again. Now on to the loop...

4. Make another state to do something with the array entry. In my case it's a string array and I'm comparing the individual strings to text that the player inputted at the beginning. I'm calling my state "CheckLetter" in the attached images.
5. Back in ArrayListGetNext, set the "Loop Event" to that new state.
6. Now back in the state that does the comparing, set the false condition to go back to the ArrayListGetNext state. This way it will keep looping until it finds the entry you're looking for.
6. Set the true state in the comparer to move on to a new state that does something with the entry. In my case it's "DisplayLetter" that just prints the entry to the screen.

You now have a setup that loops through an array until it finds what you're looking for and then moves out of the loop to do something with it. (I'm ignoring the "Finished Event" and "Failure Event" for now)

Now for the final step. Once you've done something with the entry, at some point we're assuming you want to start the whole thing over again, looking for a different entry in the same array. The problem is that by default, ArrayListGetNext will pick up where it left off, so if the new entry is before the last one you looked for, it will continue to the end and fail. Jean's new upgrade fixes this.

7. Make a new state. I called mine "ResetArrayPointer".
8. In this state, add a SetBoolValue action. Remember the reset Boolean we made at the beginning? Use the SetBoolValue action to now set that value to true.
9. Now back in the last state you made, the one that did something with your output, add a "FINISHED" event and hook that up to the SetBoolValue state.
10. Finally, add a "FINISHED" event to the SetBoolValue state and hook that up back into the ArrayListGetNext state, and you are done.

Now what should happen is that ArrayListGetNext will initially see the "Reset" Boolean as false and start looping through the array entries. When it finds what you're looking for, it will exit the loop and do something with the entry. After all that's done, it will set the "Reset" Boolean to true, meaning, "Hey, I've finished doing what I needed, now I want to start completely over". The next time the ArrayListGetNext state is entered, it will see that "Reset" is now true, and start at the beginning again!

Anyway, sorry for the length of the post, but I wanted to be sure I gave all the necessary info. Better too much than too little. Attached you will find two images showing how I have things set up. I hope I've made it simple enough that it'll be self-evident how everything should be set up.

Thanks to Jean for his never-ending help. Hope this helps :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array List Get Next not resetting?
« Reply #13 on: June 03, 2014, 08:05:05 AM »
Hi,

 :) thanks for this. Indeed I can't really think of another way to have a reset system on an action. The other option would be to create a new set of similar actions where you actually have a variable storing the index, and so coming back to the action always increment the index by one, so you can leave, set the index back to 0 and start again. The issue with this would be that it would have to be a new action to not break compatibility with previous projects using the current get next, and my reset system is backward compatible.


bye,

 Jean

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Array List Get Next not resetting?
« Reply #14 on: July 28, 2014, 03:32:06 PM »
Hi  Jean,
I just tried the new Get Next action, and I got all my previous Get Next action resetted.
The variable and type are empty.
I am fixing it by hand since I need to move on, but you should put some kind of warning.
There is a warning on the wiki page, but you wrote in your last post that it was backward compatible, so it's a bit confusing.
Just wanted to let you know.
bye,
Yaniv

Visit my portfolio: http://www.yanivcahoua.com/