Writing INI files to an Array using a Loop?

This forum is currently in read-only mode.
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi,

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

    Example:

    >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?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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:

    [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.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)