playMaker

Author Topic: How to exactly initialize ArrayTables?  (Read 1515 times)

JohnLabern

  • Playmaker Newbie
  • *
  • Posts: 6
How to exactly initialize ArrayTables?
« on: May 09, 2023, 12:43:25 PM »
Howdy!

I'm doing a grid inventory system in which you can define the rows and columns for each of my containers (sometimes generated at runtime). My first idea was to create an Array List Proxy for each row but then I saw in the forums some sort of '2D arrays' (ArrayTables) exist, which could be a more elegant solution for approaching this inventory system. Also the Array Table Contains action could be very useful for searching items, instead of iterating each list.

I see that the "Array Table Add Row" action requires an array. I start the FSM by adding a number of items to an array equal to the desired number of columns.

The problem is that when I try to iterate the Add Row action using this array as many times as rows I want, I get an error:

Column count not matching the newRow count for /MasterOBJ/PlayerInventory:Fsm(CreateInventory):State(GenerateListRows):Action(ArrayTableAddRow)

The only components I have in the GameObject so far are the main Behaviour FSM and the Array List Table.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How to exactly initialize ArrayTables?
« Reply #1 on: May 10, 2023, 08:05:40 AM »
Hi.
i would use a simple array for inventory.

Any specific reason you want to do this in a grid array?

JohnLabern

  • Playmaker Newbie
  • *
  • Posts: 6
Re: How to exactly initialize ArrayTables?
« Reply #2 on: May 10, 2023, 09:46:27 AM »
Hey djaydino,

I used an array for a simple inventory in the past, in that case every item occupied a single slot.

In this case I want items of different sizes and containers of varying rows and columns (ala Diablo or Tarkov), hence I thought having some kind of 2D array would help me resolve the problem better.

Anyways, I think I'm going to approach it by using Array List Proxies, columns are their length and rows the number of lists, isn't this almost the same as ArrayTables? ;D
« Last Edit: May 10, 2023, 09:48:02 AM by JohnLabern »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How to exactly initialize ArrayTables?
« Reply #3 on: May 11, 2023, 04:39:34 AM »
Hi.
Yes its virtually the same.

you can name your array Lists 0 / 1 / 2 / etc
then you have a grid number based :D (Array 0 (x) / index 0 (y)