playMaker

Author Topic: Array Maker Problem  (Read 2519 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Array Maker Problem
« on: April 16, 2017, 05:04:13 AM »
Hi!

Can someone explain me how "Array List Get Previous" works? Because it doesn't work as I thought or want. I try to use Array Maker for the Game Menu for the first time. I add all the menu buttons in an Array List. When I click down key, I use Get Next. When I click up key, I use Get Previous, but it doesn't get previous.

I have these buttons:
-Play
-Game Modes
-Highscores
-Options
-Quit

It works fine with Get Next, but not Get Previous.
Can someone explain me how to set up the logic here?

How should start index and end index be in Get Previous? In Get Next, I have 0 on start index and 4 on end index. On Get Previous, should start index be 4 and end index be 0? I have tried many variations here, but Nothing works as I want. I really appreciate if I can get some help with this.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Array Maker Problem
« Reply #1 on: April 16, 2017, 05:18:19 AM »
If Get Previous has 0 as start index and 4 as end index, and when I press the up key, the Array List goes to Quit button. If I click one more time on the up key, it goes to Options button. And one more time, it should go to Highscores button, but no...it goes back to Quit and then Options, Quit, Options, Quit, Options, etc. Why?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

firesidegames

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Array Maker Problem
« Reply #2 on: April 16, 2017, 07:57:21 AM »
Can you share a screenshot of the exact setup you have for your actions including what settings are used within the action itself.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Array Maker Problem
« Reply #3 on: April 16, 2017, 12:14:53 PM »
Hi!

I don't have that much on the FSM yet. Only Get Key Down/Up and Array List Get Next/Previous. The point is that, Get Previous doesn't go through all the indexes in the array list. I attach 2 screenshots.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Byromaniac

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Array Maker Problem
« Reply #4 on: April 18, 2017, 03:02:03 PM »
those actions are more for looping thru the array and iterating on each item, if i remember correctly. if i understand what you are looking for, the way i do this is to get the length of the array. subtract 1 to get the proper end of index (cuz length starts count at 1 and index starts at zero). when you click next, add 1. check to see if you are greater than the end. if so set the index back to zero, if not continuie. get the item at that index. go back to the listener. previous is just the reverse

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array Maker Problem
« Reply #5 on: April 19, 2017, 02:49:22 AM »
Hi,

 you should not use these actions for this, I see the names are misleading and I understand why you wanted to use them, but they are meant to be used for looping trhough items, not just to get the previous item... unless you maintain all your indexing right which is a pain.

 instead do the following:

 have an int variable representing your current selected index, and when you sant to get the next or previouw, you add or substract to this current index, you check you are still within range (liess than 0 then you want to access the last item, if more than last item you want to access item 0) and you then get the item at that new index.

 this way you have total and clear control.

Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Array Maker Problem
« Reply #6 on: April 19, 2017, 07:53:31 AM »
Quote
have an int variable representing your current selected index, and when you sant to get the next or previouw, you add or substract to this current index, you check you are still within range (liess than 0 then you want to access the last item, if more than last item you want to access item 0) and you then get the item at that new index.

Hi!

So I should use "Array List Get". Now I have the following states.

State 1:
-Get Key Down - Up
-Get Key Down - Down

State 2 - Next Item:
-Int Add 1 (I store this in a variable I call Current Index)
-Array List Get - And I use Current Index in the "At Index" field

State 3 - Previous Item
-Int Add minus 1 to the Current Index)
-Array List Get

And to get the first and last item, should I use Int Compare or Array List Last Index Of?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Array Maker Problem
« Reply #7 on: April 19, 2017, 10:17:30 AM »
Last item, array list last index - Yes.

First item, is index 0, so can't you just use array list get, at index 0?

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Array Maker Problem
« Reply #8 on: April 21, 2017, 03:51:36 AM »
Hi!

In the Next Button State, I use Last Index Of. The last Index is the Quit button, then it goes to the next State, Last Index. Then I set the Current Index back to 0, but if I use Array List Get, and use Current Index, then the Play button will be selected, but then the Quit button will not be selected. How can I solve this, so all the button will be selected and then go in loop all the time? Hope you understand what I mean. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array Maker Problem
« Reply #9 on: April 26, 2017, 03:49:14 AM »
Hi,

 you need to debug your indexing and how you keep track of the current index, and under which condition you enable disable buttons, it's always requiring a bit of fiddling, for everything to fall into places and all corner cases to be fully working.

 Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Array Maker Problem
« Reply #10 on: April 27, 2017, 06:16:39 PM »
I know, but I found another way also, using array. It's not only one way to do it. :)
Maybe I will experiment a bit with this later, but for now, it's working fine.

Just another Array question. Is it okay to use Find Array List and then Array List Contains Game Object, to find a specific game object? For example if I need to find the camera, player, game manager, etc in an Array List. It's not too expensive to use this comparing to Find Game Object which I have heard that is very expensive and not recommend to use?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no