Setting up Level-specific attributes via tables

Hey all -
I'm going through Tshirtbooth's video tutorial on how to use tables to bypass a lot of shenanigans for setting up Level/Scene-specific attributes - stuff like "score to win" and "number of enemies" that have to be game attributes for actors to see them, but have to be reset to new values every time you change a scene.

@Tshirtbooth, thanks for the video!
But, could you - or anyone else - tell me how would you change game.level - the attribute reading the current level/scene of the game? I see that the "SetUpAttributes" actor sets those game-level attributes to the appropriate values according to positioning in the table, but tshirtbooth uses "game.level" to which set of attributes in the table to set everything.
How the heck do you change game.level itself without using a unique actor for every single scene to set the game.level attribute manually, which is exactly what using tables was supposed to avoid?
I'm going through Tshirtbooth's video tutorial on how to use tables to bypass a lot of shenanigans for setting up Level/Scene-specific attributes - stuff like "score to win" and "number of enemies" that have to be game attributes for actors to see them, but have to be reset to new values every time you change a scene.

@Tshirtbooth, thanks for the video!
But, could you - or anyone else - tell me how would you change game.level - the attribute reading the current level/scene of the game? I see that the "SetUpAttributes" actor sets those game-level attributes to the appropriate values according to positioning in the table, but tshirtbooth uses "game.level" to which set of attributes in the table to set everything.
How the heck do you change game.level itself without using a unique actor for every single scene to set the game.level attribute manually, which is exactly what using tables was supposed to avoid?
Answers
How do you avoid this? How can you tell the "Level Set up" actor "Recognize WHICH level you are on, and change game.level to that number"?
I.E.
When (Player finished level)
Change Attribute: level # = level # + 1
I hope that helps.
C
You dont want to change it to level+1
Say your on level 2 and you beat it, itll change to level 3. But what if you want to replay level 2, then itll be pulling values for level 3 when your still on level 2. So you just want to change it to whatever level number your on.
I just did a little test and found something interesting out.
I made a table with 1 column, and 2 rows. The first row has 3 in it, and the second row has 7 in it.
Then i named the first scene 1, and the second scene 2.
I made one actor and unlocked it in each scene, so i can gain access to the scene attributes.
i then told it to display text: tableCellValue(game.Table1,scene.Name,1)
And it worked. When i was on scene 1 it displayed 3, and when i was on scene 2 it displayed 7. Since the scene names were 1 and 2, it used that number(the scene name) to specify which row to use.
Now i didnt take it any further then that, but you can try replacing the game.level attribute in the table cell value with scene.Name if your scenes are number 1,2,3 and so on based on what level they are, and see if it works. (havent tested that though)
Then you wouldnt need the change attribute game.level in each scene to specify what row or column to use cause it would pull it based off the scene's name number, but the thing about that is youll have to have the actors that need to access the table unlocked so they can get access to scene.Name.
Not sure how practical this is but maybe this info will help you out a little.
As for iterating the actual actors in a scene, it all depends on how deeply you want to change the information from level to level. If it is a side scroller, then you would have to keep track of starting positions as well as actors. The table could be as simple as three columns:
1) actor type
2) x-coordinate
3) y-coordinate
The problem with this however, is that you wouldn't be able to visually define where the actor would end up until the level started. It is much easier with static positions where the objects may change. You could set it up in a grid where each position may, or may not have an actor. Those positions have static (x,y) coordinates that you know where they are. So, row 1 is the upper left of the screen, you can place an actor in row one and it will spawn in the upper right corner. The issue with this depends on the fidelity of your grid. A 10x10 grid would have 100 possible starting positions for actors. A 20x20 grid bumps up to 400 positions, etc.
I don't know if that makes sense, but I hope it helps..
C
Yeah but thats more work then simply having 1 change attribute in each level changing game level to what level that scene is . Why would you want to create more work for yourself when you can just have one change attribute behavior?
1) You need to have a global variable to iterate your level select.
2) If you want to have a table to keep track of the actors in your levels, you need to decide how much info you need for their starting position.
Regardless, there is no way to get around designing the levels from scratch. @Tshirtbooth was saying basically that if you want level 2 to be different than level 1, you call a different row from your table that holds all your level 2 info instead of your level 1 info. That doesn't mean you don't have to design level 2 separate from level 1. You don't need to create a separate scene with separate actors if you don't want to. Everything could be called and spawned from tables. Whether or not that makes sense depends on the type of project a person is making.
I think the original question was, "How do you change the level without changing everything else?" The simple answer is, "Don't change everything else. Just change the level."
The rest was more to explain other options beyond changing the level. Probably more information that OP wanted, or anyone else for that matter!
-C
So I have my actor "Level Set up" and in it I have the commands to change the game-level atttributes to the corresponding values in my table.
I go to my scene, and I drag in the "Level Set up" actor. This actor cannot access currentScene.Name, so I double-click on the actor within the scene and am taken to the Actor's inner workings, with the giant Lock-icon. I click on the lock icon to unlock it, and then I can go into the Actor's inner workings and actually input stuff like currenScene.Name where I want it.
However, it seems that these changes do not correlate to the original "Level Set up" actor when I double-click on it from within the Actor list. Also, I have to redo these changes when I put in the actor into another scene.
So what am I modifying, exactly? It is simply a specific, modified instance of the "Level Set up" actor that the scene will remember and work with correctly? And I will have to do this for each scene? (Not a big deal at all, just trying to clarify). Is what I'm doing correct?