How do I initialize an array and retrieve its value by position?

0 favourites
  • 2 posts
From the Asset Store
Vector illustration of a UFO with an alien in three different positions.
  • I have the following data:

    10,15,10.5,15.75,11.025,16.5375,24.8063,17.3644,12.1551,18.2326,12.7628,8.934,6.2538,4.3776,3.0644,4.5965,3.2176,2.2523,3.3784,5.0677,7.6015,11.4023,7.9816,5.5871,3.911,2.7377,4.1065,2.8746,2.0122,1.4085,2.1128,1.479,1.0353,0.7247,0.5073,0.7609,0.5326,0.799,0.5593,0.3915,0.5872,0.8809,0.6166,0.4316,0.6474,0.9712,1.4567,1.0197,1.5296,2.2944,3.4415,5.1623,3.6136,2.5295,1.7707,1.2395,0.8676,1.3014,1.9522,2.9282,4.3924,3.0747,2.1523,1.5066,2.2599,1.5819,2.3729,1.661,2.4915,3.7373,5.6059,3.9241,5.8862,8.8293,6.1805,4.3264,3.0285,4.5427,3.1799,2.2259,3.3389,5.0083,3.5058,5.2587,7.8881,11.8321,8.2825,5.7977,8.6966,13.0449,19.5674,13.6971,20.5457,14.382,21.573,32.3595,48.5393,33.9775,50.9662,35.6764

    I want to load it into an array and then retrieve any of its values by calling its position in the array, i.e. arrBill.At(0).

    How do I load it up to begin with?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • farmersfable

    there are many ways to do it - if the data isn't likely to change after you export your game, then you can copy and paste the data into a text variable and use tokencount and tokenat to break it apart and put in the array.

    you could also add a text file to the project and load that, or you can use AJAX to request the data from a database, or other external source at runtime.

    I made a quick sample of the first option...

    https://www.rieperts.com/games/forum/loadarray.capx

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