Equipment Array and Populating a List

For questions about using Classic.

Post » Sun Nov 02, 2008 12:11 pm

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:
[code:2q19lrf2]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.
B
3
S
1
G
4
Posts: 37
Reputation: 1,299

Post » Sun Nov 02, 2008 3:37 pm

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
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Nov 02, 2008 6:42 pm

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.
B
3
S
1
G
4
Posts: 37
Reputation: 1,299


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests