Question - Calling table by attribute name?
Quick question. I have the feeling the answer might be no, but is it possible to use the tablecellvalue behavior with an attribute as the table name?
The deal is this: I have several tables, each with a bunch of x,y values to spawn obstacles, Tab_Obs_1, Tab_Obs_2, etc. I want to be able to pick a random table, then spawn actors at those values.
So...
Rule: If obstaclespawn triggered, then
Change attribute Obs_Table to "Tab_Obs_"..random(1,5)
Spawn actor
at x= tablecellvalue(Obs_Table,row,1)
at y = tablecellvalue(Obs_Table,row,2)
iterate row...
This doesn't seem to be working. If it is not working because it simply doesn't work this way, does anyone have any alternate suggestions that don't include making one massive table? Haha, thank you!
AirshipScientist
Comments
Hey @AirshipScientist,
My first question I have is do you have a table for each obstacle?
@KillerPenguinStudios
No, essentially what I am doing is that I have a table with 5 to 10 pairs of x,y coordinates, each representing an obstacle spawn point. So I have multiple tables, each with multiple spawn points contained in it. Each time I call a table, I want it to spawn an obstacle at every point in the selected table.
Essentially what happens is that a hero actor triggers a new, random table of obstacles as he moves forward.
An alternate suggestion:
You could make a game attribute "whatTable"
Then a Rule: If obstaclespawn triggered, then Change attribute game.whatTable to random(1,5)
Then make another rule for each of the possible tables:
When game.whatTable = 1 Spawn actor at x= tablecellvalue(Table1,row,1) at y = tablecellvalue(Table1,row,2)
When game.whatTable = 2 Spawn actor .... and so on.
@kolabo
Thanks for the suggestion, I may give that a go. I guess that would be complicated if I end up having a lot of tables, as I'd need an if statement for each, but I think that could work for now.
you can't reference the table by an attribute, but why don't you have a single table with multiple columns? You could merge your existing into a single table
col1 = table1x
col2 = table1y
col3 = table2x
col4 = table2y
etc...
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
@jonmulcahy
That's a great idea. I guess I hadn't done that originally since it seems more clean to have a table for each, but I suppose there's no reason why I can't just have one massive table. Then I can randomly select a number (an odd number) for the x values, and then that number +1 for the associated y values.
Thanks!