How do I extract values from a selected array value

0 favourites
  • 3 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi,

    I hope this make sense

    I was wondering if there was a way (like unix split) within Construct 2 to go through each character within a specific array element.

    Meaning that if I have an array with 10 values 0-9 on X, with different names such as

    0,0 = DOG

    0,1 = CAT

    0,2 = FOO


    Then I pick one of these from the array, then foreach letter within the selected choice put it somewhere.

    So for example I wanted to extract D and put it in square 1, then O put it in square 2 then G in square 3.

    I did this before, but what I ended up doing was just creating an array with one x, then 5 height(Y) and go through each on of the Y's, bit this ended up being very long in the tooth.

    Would I perhaps need to create an array from the selected number then pop them off or something?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The question is what do you want to do with each letters ?

    You can go and have a loop that will read the content of the array at specific coordinates, letters by letters.

    Example you want to display the letters in a text object. That would give something like :

    For "wordLength" Start 0 End len(,coordY))

    Text.text = Text.text & " _ " & mid(,coordY), loopindex, 1)

    Will give

    "D _ O _ G" (possibly even "TextD _ O _ G")

    for coordX = 0 and coordY = 0

    No need for an extra array in that case.

    Text manipulation system expressions are awesome.

  • Whoooaaa. I think I will need an hour and 2 cups of coffee to understand that but I think I might be able to work it out. Basically I don't want to append to the same text box, but to a individual text boxes for each character like a crossword layout.

    Thanks Kyatric. I will see what I can do with this.

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