Actors Checking Tables

I still can't figure this out...
I have a Level Selector Scene where a user can select their level, but I only want them to be able to select the next level if the previous level was completed.
I am trying to use tables, but I can't find a rule or behavior that checks with a table value before moving to the next level.
Any help?

Comments

  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    Instead of checking if each individual level has been beaten, store the highest level that has been. Then all you need to do is set up a simple rule with "is my level less than or equal to the highest level beaten?" If so -> Unlock.

    I would throw together a demo, but I am on the road. If you still need help in a few days I'll put something together.
  • VoltzStudiosVoltzStudios Member Posts: 38
    How do I set up a condition? When I add an attribute condition, I can select the table, but I can't set a value equal to anything.

    Thanks.
  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    Tables cells in rules are a little buggy. They can only be on the right side of the opererator. So you need to use the attribute first.

    When Self.Level is lessthan or equal to (select this from the drop down list in the expression editor) TableCellValue(yourtable,1,1). Replace "yourtable" with your table, selected from the attribute list. Then specify the row and column where the value is stored.
  • VoltzStudiosVoltzStudios Member Posts: 38
    That makes perfect since. I figured out what I need to do and applied that, but when I test it, things don't work correctly. I will try to see if it's my error (probably is).
  • VoltzStudiosVoltzStudios Member Posts: 38
    edited May 2013
    So would "if self.LEVEL <= TableCellValue(game.LevelsComplete,1,1)" be correct?


    When I test it, I can't click on the first level (The table value is 1 and the self.LEVEL is also 1, both integers)
  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    That is how it should look. Perhaps post a screenshot of your rules?
  • VoltzStudiosVoltzStudios Member Posts: 38
    image
    I think that's right. Take a look, tell me if you need more. Thanks.
  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    Huh. Assuming all your other code is sound I have no idea what's wrong. I've noticed if you have faulty logic, GameSalad just stops running behaviours encountered after that. Is there a chance you have some game breaking logic somewhere else?
  • VoltzStudiosVoltzStudios Member Posts: 38
    I have no idea. I'll check tomorrow as I am going to bed now. I'll update you tomorrow. Thanks for the help.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Is there a reason that you're using tables for this? If you just need to compare the current level to the number of levels completed, you'd want to use an integer attribute instead of a whole table. A table would be useful if you were unlocking each level and keeping track of which level(s) had been unlocked (e.g. levels 1,2,3,7, and 13).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • VoltzStudiosVoltzStudios Member Posts: 38
    Oh, well I have an actor (your character) that when it touches the finish actor, it changes the table value, and I am trying to make it so that on the levels scene, the level actors only unlock if the previous level was complete.

    Maybe there is a simpler way to do things. I just started with GameSalad and it's all new to me.
  • VoltzStudiosVoltzStudios Member Posts: 38
    @ShmirlyWhirl All of the code for each Level Selector is the same as that screenshot from before. The only other codes I have are "On Touch switch to scene" (and that is for the initial menu which goes to an About page and back, and from the main menu to the level selector scene.)
    The only other thing I can think is it has something to do with the main character actor. I will try to get a screenshot of that up if you could take a look at that for me. :)
  • VoltzStudiosVoltzStudios Member Posts: 38
    edited May 2013
    image

    This is for the main character actor (What you move around in each level). Right now, when it touches the Finish actor, it should change the table value, and switch to the Win scene that says "Level Complete!"
    I think the above is correct, but it doesn't seem to be working.
  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    @tatiang
    I suggested using a table cell because I've been using tables to store all my miscallaneous game data. I think it makes things smoother when you don't have to save/load attributes every time the game is opened.

    @VoltzStudios
    I'm away on a buisness trip right now, but I'll be back at my computer tomorrow. If you're still having this issue I'll throw together a project that does what you're trying to do. Looking at your code, I have no idea what's wrong.
  • VoltzStudiosVoltzStudios Member Posts: 38
    @ShmirlyWhirl Alright, cool. I set aside today to work heavily on the app, so I will do everything I can to try to fix whatever my problem is. Thanks, and good luck with your business stuff ;)

    And in reply to @tatiang, I was just reading that storing information in tables is highly suggested because it keeps all of the game data in a central location. I'm sure there are other ways to do things, but I am going to stick to tables unless there is truly a simpler way to do things.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Okay, take a look at this:

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • VoltzStudiosVoltzStudios Member Posts: 38
    @tatiang Thanks, that is actually the template I started out with, and it worked until I started adding level content, so I remade the table and now nothing works. I may just start over again. It could be because that was a mac template and I am using the windows version of GameSalad until I get a mac.
  • VoltzStudiosVoltzStudios Member Posts: 38
    @ShmirlyWhirl I got it to work :)
    It was really my fault. In the actor, I had TableCellValue instead of tableCellValue... Apparently capitalization matters. Oh well, I got it working now.

    Thank you to both of you!
  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    Ah, I'm glad you got it working. And you learned a valuable lesson- GameSalad can be very finicky.
  • VoltzStudiosVoltzStudios Member Posts: 38
    Indeed I did. It's still better than hardcore coding with xCode or similar.
    You definitely helped me though; I would have almost never figured out the whole tableCellValue(table,1,1) thing in the first place. But now I am complete done with the level selectors all thanks to you, and 2/3 done with the levels themselves.

    Thanks again!
Sign In or Register to comment.