Equipment Array and Populating a List

This forum is currently in read-only mode.
From the Asset Store
Easy to use shop and inventroy populated by an array!
  • I'm constructing a game where the player pilots a ship that can use various equipment. So far, I've created an array to store ship data, which looks something like this:

    Name Image Space Weapons Speed
    Name Image Space Weapons Speed
    etc...[/code:2q19lrf2]
    
    As far as I can tell, that part goes smoothly. But I am having trouble populating a List object with my data. I know how to do it in pseudo-code, but not sure how I would translate it into events.
    
    Basically, I set up my arrays. (In the future, I will just load them.) Then I set up my list with four columns (image is excluded, that's just what sprite the ship uses)
    |Name|Space|Weapons|Speed|
    
    My trouble is looping an event to give the List all my array info. I'd imagine it would look something like this:
    [code:2q19lrf2]
    yLoop (arraysizey times)
    {
       xLoop (arraysizex times)
       {
          populate column by column
          ++array_x
       }
     ++array_y
    }
    [/code:2q19lrf2]
    
    Can anyone shed some more light on how to accomplish this using events, and a bit more info on the List object? I want my events to be as flexible as possible for when I start adding more data to my arrays. Right now it doesn't input any data at all, and I could upload my broken .cap if anyone wishes to see.
    
    Edit:
    I took out loops and just used variable comparisons, and now it's 50% working. It gets everything into the List, except it's in one column. I now need to put each item into a different column. Any help is appreciated.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You probably want to use the 'For' loop in the system object's conditions. To be honest, considering there are so few columns, you may as well only have a Y loop. I'd do something like this:

    + For "y" from 0 to array_size_y

    -> Insert new list item

    -> Set item texts using (0,loopindex("y")) etc

  • Thank you, I will try that later after finishing some stuff up. I messed around with it a bit after my edit and I got it to display all the values, except it would move one row down after each entry, but hopefully your method won't have the problem.

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