Sequence in Correct Order or Reset - Problem, please help!

DigiChainDigiChain Member, PRO Posts: 1,288
edited November -1 in Working with GS (Mac)
I have a problem and can think of a long-winded solution but wonder if anyone can come up with a simple way to do this.
Simplified here is the problem:

I have an attribute PLAYERNUMBER, this attribute changes depending on which button the player presses.
Now if the player presses the buttons in the correct combination the PLAYERNUMBER attribute value will change in this sequence for example: 5, 15, 72, 64, 102, 53...

So, I want a way of changing a BOOLEAN attribute to TRUE if the correct sequence is produced.
BUT if incorrect I want it to reset and the player to have to start the sequence from scratch.

Any ideas guys?

Comments

  • Rob2Rob2 Member Posts: 2,402
    Concatenate playernumber into a text attribute and then check for your sequence with a 'when attribute contains' rule.
  • DigiChainDigiChain Member, PRO Posts: 1,288
    If the player continually gets the seq wrong I guess the text attribute will end up being huge. Is there a limit to text attribute length? If so I don't think this'll work.

    Also, how do I actually concatenate the playernumber attribute into a text attribute?
  • Rob2Rob2 Member Posts: 2,402
    The concatenation operator is .. and is wildly useful all over the place (two full stops typed together)

    change attribute game.text to "hello ".."world" or

    game.sequence to game.sequence .. ",72"

    You shouldn't have a problem with the text attribute (thousands of characters are possible) and just reset it often to increase performance and keep things manageable.
  • DigiChainDigiChain Member, PRO Posts: 1,288
    Thanks Rob.

    I'll give this a go and see how I get on.

    Am I right in thinking then that:
    change game.sequence to game.sequence .. ",72" - will add the ,72 to the string of numbers already there?... therefore 59,64,33 would become 59,64,33,72

    And one further question then - how do I reset/clear the text attribute?

    Thanks so much for you help. How do you know and where do you find this info?!
  • Rob2Rob2 Member Posts: 2,402
    Sorry if you have been waiting on this.. I kind of forgot/lost the thread :)

    Hopefully you figured that YES ,72 would be added to your string.

    To clear an attribute just change attribute and leave blank !! Although for the sake of later debugging/reading you may want to use something sensible.

    I can't remember when the .. operator was first discovered (!) but it was quite a while ago, I'm afraid there is a fair bit of stuff that hasn't made it to any official docs yet.

    http://gamesalad.com/wiki/
    http://gamesalad.com/wiki/reference_library
Sign In or Register to comment.