How do I sort Objects alphabetical? (solved)

0 favourites
  • 8 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • Greetings and hello and as always, sorry for my english ;)

    As the headline already said, I want to know how I can sort Objects alphabetical by name or ID or anything else?

    I searched the forum but the most topics are years old and included links to files don't work anymore.

    What do i axactly want to know? Hmm ... I try to build an own "Alchemy" or "Doodle God" game (I'm sure you know, where you select two elements to create something new, like "Lava" & "Air" = "Stone", etc.)

    Everything works fine but all elements have there "fix" position in the element-list, so there are a lot of empty space between the elements until you found everything. So I would like to list the researched elements among each other and when you found a new one, it will placed alphabetical correct between the others ( I hope you understand what I mean), like:

    Earth

    Fire

    Glacer

    Land

    Vuclan

    then you research "Life" and the elements get sorted like

    Earth

    Fire

    Glacier

    Land

    Life

    Vulcan

    Greetings from Austria and thanks for your help!

    Tagged:

  • Hi.

    You can add the items that are available to the array, then sort immediately.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I found out how to add values to an array and sort them. That's easy ;) But i can "show" this only as text - How can i sort objects (sprites) in order of the sorted array?

    For example: I have the four base-elements Air, Earth, Fire and Water.

    When i combine Earth and Fire - Lava should been created. So i add the value "Lava" to the array and sort them. But how can i create a new object (sprite) with animation "Lava" correctly between the position of Fire and Water?

    And how can i prevent of creating multiple entries of the same value in the array?

    Thanks!

  • You can create an object by name.

    You can create sprites by name in the array after sorting.

    Duplicates are also simple, do everything as in a regular array in any programming language.

    You can check if there is such a value in the array or not before adding it.

    You can add but then check for duplicates and delete. You can choose any of them.

    The topic of inventory or crafting with inventory and blueprints is one of the most difficult to understand in C3. It is very similar to working with data in programming.

  • Okay. I will try. Maybe you can build a simple .capx for me? 😇

  • ".capx" I can't, I don't use C2.

    If you want, I've posted the ".c3p" source file here, you can run it in the free version of C3 and take a look.

    construct.net/en/forum/construct-3/how-do-i-8/save-multiple-scores-array-177728

    There is a part of the code where I add points to a player and I first check if that player is in the table and if he is not I add him and then sort.

    You could insert elements instead of the player name.

  • Yes, that's also a way - you post a c3p and i open it in the free version :)

  • So, I did it! I get what I want - thanks for your help!

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