How to make a table not select the same value after it is copied?
A while ago, I asked how to make a value not be selected twice when randomly selecting values. @tatiang helped me out a lot (Deleting rows off a table once the row has been selected). However, the game Im working on is an endless runner, so the table values which correspond to the pattern of enemies spawning cant just stop when all the rows have been deleted. So, once the rows are deleted, I used Copy Table to restore the table . However, there is nothing stopping it from selecting the same value twice (the last selected value in the previous table and the first value of the copied table). So 2 waves of enemies spawn in the same pattern, and I dont want that happening. Any help is appreciated, thanks and sorry if my question is hard to understand
Comments
There are probably complex ways to avoid this but what comes to mind is just (assuming you're grabbing X or Y positions from the table):
Change Attribute self.lastYposition to game.newYposition
Change Attribute game.newYposition to tableCellValue(tableName,self.randomRow,1)
When attribute game.newYposition = self.lastYposition
Change Attribute game.newYposition to tableCellValue(tableName,self.randomRow,1)
Obviously, that's not the whole set of behaviors (you'd need the randomization, table row deletion, etc.) but I hope it makes sense. The pseudocode would be:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I made a tutorial specifically for this:
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
@tatiang actually, Im taking a number off the table which corresponds to the pattern of enemies.
@Braydon_SFX I understand your tutorial but I dont quite know how to modify what you did in the video to make my game work. How do I make the value be selected every 1 second? And which attribute in the video should be the attribute that decides which enemies to spawn in my game?