Array Not Accepting Values?

This forum is currently in read-only mode.
  • Surely I must be doing something wrong, or I may have found a bad bug.

    I have an array named "Characters", and at 3,0 there is the value 340 (I have an initializing event set up) . I also have a text object for testing if I did this right.

    My string is this:

    "Character's HP is " + str(Characters(3,0))

    So, at 3,0 I should have gotten a value 340. Instead I have a 0, every time. I even tried other elements and got 0 for each one. To test further I saved the array to file and it was pretty much blank except for boxes and the text "ARR1.05".

    Have I stumbled upon a bug or did I do something wrong?

  • arrays no longer start at 0

    start at 1 instead of 0 and it should fix the problem

  • How do you initialize the value?

    Also, you don't have to use + and str() to display text; just use &, which concatenates strings; it will automatically convert numbers to text that way. So,

    "Character's HP is " & Characters(3,0)

    Okay, I just realized it. The Array is 1-indexed; the 0 is out of bounds, it doesn't exist. Rows and columns begin at 1; you should be setting it to (3,1), not (3,0). Actually, you can skip the second number and it will automatically get the first row.

  • How do you initialize the value?

    Also, you don't have to use + and str() to display text; just use &, which concatenates strings; it will automatically convert numbers to text that way. So,

    "Character's HP is " & Characters(3,0)

    Okay, I just realized it. The Array is 1-indexed; the 0 is out of bounds, it doesn't exist. Rows and columns begin at 1; you should be setting it to (3,1), not (3,0). Actually, you can skip the second number and it will automatically get the first row.

    Oh wow, that did it. Didn't realize it was 1-indexed. That got it working.

    That needs to be included in the Wiki, I don't know if I can add that in myself.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Everything is (or at least should be) in a 1 based index now.

  • > How do you initialize the value?

    >

    > Also, you don't have to use + and str() to display text; just use &, which concatenates strings; it will automatically convert numbers to text that way. So,

    > "Character's HP is " & Characters(3,0)

    >

    > Okay, I just realized it. The Array is 1-indexed; the 0 is out of bounds, it doesn't exist. Rows and columns begin at 1; you should be setting it to (3,1), not (3,0). Actually, you can skip the second number and it will automatically get the first row.

    >

    Oh wow, that did it. Didn't realize it was 1-indexed. That got it working.

    That needs to be included in the Wiki, I don't know if I can add that in myself.

    just glossed over my elegantly simple reply, didn't you?

    just kidding

    ...you did though

  • He did! *points accusingly*

  • He did! *points accusingly*

    Mipey, Lucid, thanks for the responses! :O)

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