Hi folks, is it possible to choose which column the loop over table function works on? If not, a work around? This is an attempt for dynamic selections.
@fmakawa, the loop over table behavior allows to to choose the orientation by which you loop, i.e. by rows or by columns.
Which columns or rows you act on, you determine by your code which you place inside the loop.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
@Hopscotch I can't seem to make it loop over table specific columns and read/index the data there. It does it for the column or row but I have multiple columns with lengths of data. One column has 20 cells another has 12 etc. I want to be able to point to a specific and read data there.
@fmakawa I fail to see where your problem is.
The loop over table behavior allows you to either step through a range of rows OR columns of a table.
Here is a table:
RowNumber Column1 Column2 Column3
1 23 41 12
2 36 27 83
3 19 12 46
Let us assume that you want to step through all the rows, adding the values of column 2. This would be your code:
If you want to step through all the columns, adding the values of row 3, then this would be your code:
p.s. I used adding values as a short example. There is a more powerful tableColSum function to do this though.
@Hopscotch and if the columns have differing lengths? As in one has 23 cells, the other has 14 and another 35. I am trying to spawn actors. The actors according to how many cells have data and the actors will also derive their data from said cells such as name etc. If I'm not mistaken the above method will pay attention to longest column length which is 50. Am I mistaken?
@fmakawa, all rows in a table always have the same amount of columns. Maybe you choose not to fill all of them, but then you need to have a rule to check for this.
I still do not quite know the structure of your table. Maybe post a screenshot and explain. My feeling is that there will probably be a better way of doing it.
Why do you need to loop over the table at all? Are the rows the levels or enemy waves, and the details about the enemies in the columns?
I am spawning actors according to number of filled cells per column. The individuals actors know what do with each number given. So I need to recognise that and then spawn accordingly.
@fmakawa, ok, so each column is a level, and down the rows are the enemies of that level?
Then I would suggest using the normal loop behavior, not loop over table.
Change attribute game.currentLevel = 1
Change attribute self.rowindex = 1
Loop While all
Attribute: self.rowindex <= tableRowCount(enemyTable)
Expression: tableCellValue(enemyTable, self.rowindex, game.currentLevel) > ""
Change attribute self.rowindex = self.rowindex + 1
end of Loop
Also that table is set to text and you are using numbers you need to change those to integers not text if you want to add them or port them to integers.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Great! @Lost_Oasis_Games but would that not add zero values at the bottom hence count cells it shouldn't?
I worked round it by creating an attribute that already knows how many cells have the right amount of values.