Set 2 values in one cell of an array

0 favourites
  • 4 posts
From the Asset Store
Easy to use shop and inventroy populated by an array!
  • Hello! How do I set 2 values in one cell of an array? Thanks for the help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can't really unless you store them as tokens in a string. eg "1,2" then use tokenat() to get them and int() to turn them back into values.

  • You can't really unless you store them as tokens in a string. eg "1,2" then use tokenat() to get them and int() to turn them back into values.

    Thank. Your advice helped me.

    Is it possible for two values in the cell to add a third before the first?

  • That's actually what multidimensional arrays are for. Set array Height=3 and you will be able to store three values per each X element. (on Y axis)

    For example:

    WeaponsArray set value at (X=0, Y=0) to damage
    WeaponsArray set value at (X=0, Y=1) to ammo
    WeaponsArray set value at (X=0, Y=2) to maximum_ammo
    
    To get ammo of weapon 0: WeaponsArray.At(0,1)
    

    If you have 2D array, use Depth=3 and store values at axis Z.

    If you are already using 3D array, then you can store multiple values in comma-separated strings, as mOOnpunk recommended.

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