Best way to do unlockable costume parts?

I'm trying to figure out what the best way to go about this would be.
At the moment I have a character customisation system that works by just having a button that when pressed changes game.head to (game.head+1)%8
However I want to be able to unlock some parts as the game goes on, and they may not be unlocked in order either.
What would be the best way to do this?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You might want to use a table instead. That way you can have each part on a separate row and unlock columns as needed, but not necessarily in order.

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

  • MattcusMattcus Member Posts: 85
    edited January 2015

    @tatiang I was thinking tables would be the way to go, How would I do it if I have 4 categories (Hair, Head, Torso, Legs) and how could I cycle through them in game?

  • MattcusMattcus Member Posts: 85

    @tatiang I figured out how to do it with 4 categories have a column for each category and the row for each part since all parts will be part of a full set of four. I still don't know how I could cycle through them though

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    Can you explain what you mean by "cycle through them"? Will you have a button that advances to the next head, for example? You would just increase the column number: Change Attribute game.columnNum to mod(game.columnNum,4)+1

    Make sure the value of game.columnNum starts at 1 (or any value from 1 to 4).

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

  • MattcusMattcus Member Posts: 85
    edited January 2015

    @tatiang Oh ok, sorry, my scene is basically the character in the centre with 4 buttons on either side, when you tap the button on the right closest to the head it goes to the next head, and so on for each part, However I need to be able to skip one if you haven't unlocked it yet.
    Do you know what I mean?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Oh, I see... if you haven't unlocked one. Hmm, a bit trickier then.

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

  • MattcusMattcus Member Posts: 85

    If it would make it easier, I could change the system to instead of cycling through, it shows a grid of all the unlocked parts? Maybe?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Maybe. I'm going to see if I can make a demo... not sure how much time I'll have.

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Here's how I'd set up one of the parts and you'd use the same logic but a different row number for the other parts.

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

  • MattcusMattcus Member Posts: 85

    Thanks so much, that helped a lot!

  • MattcusMattcus Member Posts: 85

    @tatiang Hey, thanks for your help so far, however I found an issue, the image doesn't change if there are two unlocked parts in a row.

    For example I have 8 heads at the moment, if every second one is locked, it works like it's supposed to, but both 5 and 6 are unlocked, however when tap the button to go to the 6th head, it stays as the 5th image.
    Any idea how to fix this?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Swap out the first Change Attribute behavior for a Constrain Attribute behavior. I originally had that but took it out in order to try and avoid constrains.

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

  • MattcusMattcus Member Posts: 85

    Yay! It works perfectly now, Thanks for your help.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You're welcome.

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

  • MattcusMattcus Member Posts: 85

    @tatiang Sorry for bringing this up again after so long, But I need help with this again.

    The way it works as it is is fine, however I have too many different character parts that I don't want to have all the locked ones visible until you unlock them, So I need a way to cycle through the parts, skipping ones you haven't unlocked yet.
    Do you know how I could do this?
    Thanks

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I think you could do this by using the tableSearch() function starting at the current row (object) and ending at the last row (using tableRowCount). If you search the locked/unlocked column for the next unlocked value, you could use the resulting row to display that next. So each time the player presses a button to go to the next character part, you'd do a table search to determine what gets displayed.

    This is not something I've tested but off the top of my head, I think it should work.

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

  • MattcusMattcus Member Posts: 85

    I've never use the search table function before, and it's a little confusing, like what is the key? What do I need and what do I delete etc?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I agree, it's quite confusing. Hopefully this video will help explain it:

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

  • MattcusMattcus Member Posts: 85

    Ok so If the final column is unlocked, It works fine, however doesn't go back to the start. If the final column is locked, it goes to the last unlocked part, then the next time you press the button, it does nothing, then the next time you press the button it goes to column 0 meaning the actor turns white, then when you press the button it goes back to the first unlocked part. Any ideas what I should do next?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    What is the rule you're using for changing the column? And why would it be changing to 0?

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

  • MattcusMattcus Member Posts: 85

    Let me rephrase that, i don't think it's changing the column to 0 but it changes the game.head attribute to 0.

    Anyway the rule I have set up is:

    When touch is pressed change attribute game.head to tableSearch( game.T-CharacterParts ,1,"row",2,( game.Head +1),tableColCount( game.T-CharacterParts ),"exact")

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Okay, so you're searching from column game.Head+1 to the number of columns in the table. Is it possible that game.Head+1 is greater than the number of columns? For example, if you have 10 columns and the player is viewing head #10, wouldn't game.Head+1=11? That would cause unexpected results from the tableSearch function.

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

  • MattcusMattcus Member Posts: 85

    I know that, The only reason I added the plus 1 is because it was searching for the next unlocked column, between game.head and colcount, but because game.head is unlocked it treats that as the next unlocked column. Do you know what I mean, I added the plus one to search every column after the one it is currently on.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Yes, I get it. What you might need to do is either have the rule only run the tableSearch when game.head < tableColCount(game.T-CharacterParts) or add a min() function, which can get a bit cumbersome in the expression editor:

    tableSearch( game.T-CharacterParts ,1,"row",2,min(game.Head+1,tableColCount( game.T-CharacterParts)),tableColCount( game.T-CharacterParts ),"exact")

    That will ensure that game.Head+1 is never greater than the number of columns.

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

  • MattcusMattcus Member Posts: 85

    Ok putting it inside a rule saying when game.head+1<tableColCount(game.T-CharacterParts) worked. However I need it to loop back to the start, and since the final unlocked one would be different I'm not sure how to do that.

Sign In or Register to comment.