How do I call Elements In An Array In Order?

0 favourites
  • 7 posts
From the Asset Store
Basic clone of a 80's arcade game called Gyruss that was quite fun to play!
  • I have an Array I'm using to have conversations with NPCs. I want to progress the dialuge each time the Space Bar is pressed ,which I know how to do, but instead of going in order it shows up each element at random.

    I used this code

    *When Player---> Overlaping NPC

    *Set Text To---> Choose(Array.At(0,1)Array.At(0,2), Array.At(0,3))

    I want to progress the Text Array from 1 to 3 for example but it's picking them at random like 3,1,2.

    How do I call elements in Array in oder on each Axis?

  • choose() expression does exactly that - picks one random option.

    You probably need chooseindex() expression.

    Set Text To---> Chooseindex(counter, Array.At(0,1)Array.At(0,2), Array.At(0,3))

    After each time increase the counter variable.

  • choose() expression does exactly that - picks one random option.

    You probably need chooseindex() expression.

    Set Text To---> Chooseindex(counter, Array.At(0,1)Array.At(0,2), Array.At(0,3))

    After each time increase the counter variable.

    Thank you, I’m not sure if I’m typing it wrong but it will not let me type in “Counter” ,I’m not sure why. it’ll just replace it with “cos” or suggest another expression saying (Unkown Expresstion- this is not a system expression or variable name in this scope)

    I typed — chooseindex(counter, Array.At(0,1)Array.At(0,2), Array.At(0,3))

    I have this in a sub event, is that the problem? Is this on my end?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Counter is just a name of a variable. When the dialogue starts, set counter to 0. Each time a dialogue line is shown, you need to increase it by 1. (up to the maximum number of lines)

  • Counter is just a name of a variable. When the dialogue starts, set counter to 0. Each time a dialogue line is shown, you need to increase it by 1. (up to the maximum number of lines)

    Oops sorry I see,ok it worked! Thank you so much for your help I appreciate it!😊

  • Actually, I must have had a brain freeze, you don't need chooseindex.

    Just use Array.At(0,counter)

  • Actually, I must have had a brain freeze, you don't need chooseindex.

    Just use Array.At(0,counter)

    Oh that makes it so much easier. Thank you so much for your help 😊 XD!

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