Load data from a random table
Hi guys,
I looked up on the forum and in the manual but I didn't find this.
Is it possible to have more tables and, at the beginning of the game, pick a random one and use data from that? Changing every time you play basically.
I want to create a series of level sets, but they can 't be totally random, I need to create these sets of levels in a particular way, but I also don't want the player to immediately figure out there's a pattern they can learn to proceed in the game.
Imagine a room with 4 doors, just one of them it's safe to go through, I want the sequence of safe doors to be read from a table and I want to use 10/20/... different tables so that the game is "different" every time.
I tried by creating a game attribute (text, not sure about this) and randomly assigning a table to it, but I guess you can't assign a table name as a text value and then use that attribute when loading data from the table. It doesn't work.
down here: game.table1 and game.table2 are my tables names
Is it possible to do this? Any idea?
Thanks!
Comments
You'd have two options really. The first is essentially what you said - but instead of change attribute you'd have a "working" table, and you'd copy the randomly chosen table into that "working" table. That gives you a random one each time.
The second is to make one big table, ensuring each level is a consistent number of rows of that table. For example, 10 rows per level, with 10 levels. Then pick a random number from 1 to 10 (e.g. 5), and use rows 50-60.
The first is easier, the second is potentially more efficient.
Ah that's great!
The second solution is really smart, I think I'm gonna try that one first!
Thanks for your help!
just for > @Armelline said:
Just to let you know: I used the second method you suggested and it works
Thank you so much!
Excellent! Really glad it worked and great job, that can't have been entirely simple!
sorry for the late reply.
Thanks!
Yes, it gave me a couple of headaches but it's been REALLY useful to learn how tables in GS work. Thank you once again!