Writing INI files to an Array using a Loop?

For questions about using Classic.

Post » Mon Jan 17, 2011 10:07 am

Hi,

I'm looking to Read data from an INI file and set the values an array.

Example:
[code:rt7ido1c]
>Load INI file.

>Set

[Name]
1=James

as

Array[1,1]

[Health]
1=5

as

Array
[1,2]

[Name]
1=Jeff

as

Array[2,1]

[Health]
1=15

as

Array
[2,2][/code:rt7ido1c]

Obviously it's more data than the example, but you get the idea.

The best way to do this would be using a loop, but I'm exactly sure how to in Construct. Any ideas?
B
1
G
4
Posts: 2
Reputation: 1,029

Post » Tue Jan 18, 2011 12:42 pm

I'm not sure it makes much sense to organize things in the way you showed. Wouldn't it be better to go about it like this in the INI:

[code:8t3iix3p]

[James]
Health=5

[Jeff]
Health=15

[/code:8t3iix3p]

So every group is a character and you can add attributes like you want as items. Or in case you need the character names as items too, I'd prolly just do:

[code:8t3iix3p]

[Char1]
Name=James
Health=5

[Char2]
Name=Jeff
Health=55

[/code:8t3iix3p]

And again, I would prefer to use a Hash Table instead of an Array to get the data in the game. Just create a hash table for each group and add the items as keys. Some simple loops.

In case you do absolutely need a cap example or insist on using an array (for a reason I'm not aware of), just say so.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests