Setting up Level-specific attributes via tables

frankwashburnfrankwashburn Member Posts: 32
edited May 2012 in Working with GS (Mac)
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?

Answers

  • frankwashburnfrankwashburn Member Posts: 32
    @tshirtbooth - Right, I understood that. But how/where do you change game.level = 2? Is it via a scene-specific actor that runs at the beginning of each scene to change game.level to the Level Number? If so, then if you have 80 levels, then you'll need 80 of those actors - one actor for each scene.

    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"?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited May 2012
    You can just put it in your background and change game level to whatever level that scene is.
  • frankwashburnfrankwashburn Member Posts: 32
    @johnpapiomitis - Right, I understand how fundamentally that works. It just seems really inefficient/cumbersome to have to deal with a unique actor for each scene to do that. I was wondering if there was a way to bypass that with table functionality.
  • CluvCluv Member Posts: 229
    You can put the code/rule into whichever actor won't be destroyed in the scene. It will just need to exist in each scene to make sure you move to the next. As long as the rule doesn't need the actor to be "touched" or anything, it should run regardless of which actor it is saved in. You could just save it inside of your player, since he is in each scene, and iterate levels through him.

    I.E.

    When (Player finished level)
    Change Attribute: level # = level # + 1

    I hope that helps.
    C
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited May 2012
    @Cluv

    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.

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited May 2012
    @ frankwashburn

    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.


  • CluvCluv Member Posts: 229
    @Cluv

    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.

    You can always change that number with another rule call. If you have a menu at the end of a level, then you could iterate the level from there. In the menu you would keep track of what level you are on, and depending on where you press, which level you move onto. The point is that there needs to be a call to a global variable and that global variable is responsible for the level change.

    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
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited May 2012
    @Cluv

    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?
  • CluvCluv Member Posts: 229
    @JohnPapiomitis, I don't think we are disagreeing as to the efficacy of an approach. I am describing options as to what is possible, depending on what @frankwashburn wants to do. I think there are just two points I am trying to make:

    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
  • frankwashburnfrankwashburn Member Posts: 32
    @JohnPapiomitis @Cluv Wow, thanks so much guys. That's super in-depth, I appreciate that from both of you! @John, I wasn't aware that you could get unlock actors to view scene attributes, I will definitely have to do that. Do you have that test demo saved? If you could link it I'd be grateful - if not I'll simply try to figure it out from the info you've given me.
  • frankwashburnfrankwashburn Member Posts: 32
    @JohnPapiomitis, John, quick question about your proposed implementation/the nature of Gamesalad.

    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?
Sign In or Register to comment.