Populating an array with character stats

0 favourites
  • 5 posts
From the Asset Store
Easy to use shop and inventroy populated by an array!
  • I'm trying to generate characters by randomly generating a name and 'rolling' several ability scores. I can do that without issue. What I can't seem to figure out is how to move on to the next row of the array to generate another character.

    If there are 10 different cells I want to populate with information about a character (e.g. name, age, ability scores, etc.), once that final attribute is generated and entered into the array, how do I get it to start over on the next row of the array with a new character?

  • You should post your code.

    Normally if you need to process a 2D array you can do "Array For Each XY" loop, but I prefer using two nested System For loops. If your characters are on X axis in the array and their stats are on Y axis, it may look like this:

    System For "char" from 0 to array.width-1
     System For "stat" from 0 to array.height-1
     ... array Set At (x=loopindex("char"), y=loopindex("stat")) value int(random(1,10))
    
  • Hi there and thanks for your reply.

    I've input this code, but looking at the debug it seems that it's just generating the variable only in the element at 0,0 in Array. It doesn't seem to want to move on to the next available X element, and then to the new row once Array.Width-1 has been reached.

  • Again, you need to post a screenshot of your code or your project file. It's a guessing game without it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Normally if you need to process a 2D array you can do "Array For Each XY" loop, but I prefer using two nested System For loops.

    I agree with this advice! You get easier control on when to start/end your loops, and you can "stop loop" at any time.

    But yes, sharing some more info on your project would help - there may be a hard-to-see mistake in an expression somewhere.

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