How do I Set Text To Array Value

0 favourites
  • 7 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hello All & thanks for looking,

    I can set text to Array.At(0) but how would I change that text to Array.At(1), Array.At(2), etc... with a key press or every X seconds?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • https://dl.dropboxusercontent.com/u/27336815/array.capx

    I tried it, but Array is backwards. There could be even simpler solution but so far I haven't found any. Array lacks some events in my opinion.

  • Couldn't this be solved with the array Push front action?

    https://www.scirra.com/manual/108/array

  • Thanks for the reply and the capx, Radiowaves. I really appreciate it. Your solution however has the same problem I was having, in that in order to change the text/value a different button would be needed to keep the values from escalating to their end point. I needed a one button solution so the player could just press B or A to continue the dialogue/text.

    I solved it by removing the array all together and instead added an if tree and an instance to my text container that regulates the "escalating" effect.

    I was hoping to find a more elegant solution - something like an Array.At(next) or Array.CurVal+1 but I couldn't figure it out.

    As to the push front action - I couldn't get that to work for me either (I tried). What I think that does is add another value to the cell index instead of moving the values around (which would have worked for me). Having to add a value defeats the purpose of already having the array filled and ready to go. While I'm sure I could create a dialogue tree and populate the array with it in this way - it's less work just to plug in the tree "branches" when needed.

    Thanks again, have a great day!

  • You can use a variable to track the current index:

    currentIndex = 0

    set text to array.at(currentIndex )

    when the player presses a button:

    add 1 to currentIndex

    set text to array.at(currentIndex )

  • ramones, thanks for the reply. This is (almost) exactly what I ended up doing. I used "set text" instead of an index array though.

  • You can use a variable to track the current index:

    currentIndex = 0

    set text to array.at(currentIndex )

    when the player presses a button:

    add 1 to currentIndex

    set text to array.at(currentIndex )

    An even more elegant solution involves adding a "currentindex" instance variable to the array object, in case your game logic involves keeping track of many conversations (stored in different array objects) at the same time. In that case, you use

    Set Text to Array.At(Array.CurrentIndex)

    Array Add to CurrentIndex 1

    It's much more mantainable and in my opinion a better solution to your problem

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