Condition with order

0 favourites
  • Thank you EncryptedCow, i will use your code, i found it useful for one of the game puzzles

    thatserafimkid & alextro you are right the tokenat is the best way to do things like the piano puzzle, thank you very much for your help, all of you

    thatserafimkid says : [quote:13gmrwwd]I suppose it depends on how Hunter wants to use it

    actualy i have two type of puzzle in the game, the piano puzzle (with tokenat method) and another with numbres like this :

    the numbres puzzle capx :[/code:13gmrwwd]
    this one i don't know yet what method i will use, i don't think Tokenat will be useful here, and i am sure my method isn't the right one, and i have some problems with it.
  • thatserafimkid nice solution its really awesome, but could you please explain what tokenat does?

    On the C2 manual i just found this:

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    But i dont understand what that mean and how does it work (what means Nth and token)

  • Basically array separated by the given character.

  • Hunter

    For your code game you could have all your numbers as one object, and just have the different groups be an instance variable that separates them. So you could have one sprite with 3 animation frames. and copy it 3 times and give one instance variable 'GroupName' A, then B for you second copy, and so on. Then in your code you can just change the animation frame instead of deleting and creating a new object each time. Then with tokenat you can evaluate if Sprite Group A Current Frame = tokenat at index 0. Then check group B frame at index 1, and so on. Let me know if you still don't understand


    as Somebody mentioned a tokenat is basically a one dimensional array. You can store a list of items and have them separated by a character. Let's say you made a list of your friends name


    You could find out who the 3rd person on the list is by using tokenat.

    You could do tokenat("Jon,Michael,Ben",2,",")

    This would return "Ben"

    You just have to remember that just like arrays tokenat has index 0. So the first name is at index 0 and the second name is at index 1, and so on.

    The seperator is just what it says. You tell tokenat what you used to separate your list. So in the example "Jon,Michael,Ben" we used a comma to separate our names. So we let tokenat know that every time it sees a comma that its beginning the new index, in our case new name.

  • now i understand your code, thanks

  • thatserafimkid i did it with your method, but the Tokenat Action, it is a little confusing

    i read your explination to EyeForcz, but i think i can understand better in the capx ^^

    capx :[/code:32a9cp9u]
  • Try playing CDCECD and you notice congratulation will appear

  • Hunter

    Here try this. Instead of using different animations you can just use different frames of one animation. That way your animation will match your code number and you can compare it that way. You'll see I added the code groups into a family that way you can control the animation for any of the groups in one event. All it does is add one to the frame one you click on it, and it will revert back to 0 if you click on it and it already equals 2.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thatserafimkid thank you for your quick anwsers, it is really effective with family and frames, but what i can't understand is the number after the global variable, it is not the code order, because tokenat do the order system and int convert it to integer right? but what is after the variable (CodeCombination) i can't understand it

  • That is the index of you text you are comparing. codecombination is your text. The number after that tells tokenat where to look inside the text to compare that character.

    So codeCimbination is a variable that equals "201"

    The first character in that text is at index 0. So index 0 of the text "201" is eaul to "2", Index 1 would equal "0"

    So what the code is doing is checking to make sure the frame of group A is the same as index 0 in this case "2", the frame in group B is the same as index 1 which is "0", and frame of group C is the same as index 2 which is "1"

    You can read back on a post I wrote before in this thread that explains how tokenat works.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)