User Tag List

Results 1 to 10 of 10

Thread: parsing an ini to only load a specific section

  1. #1
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2012
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    parsing an ini to only load a specific section

    hello all this should be simple i think--

    i'm sure i need to use a string parser or tokenizer of some kind, but i do not know exactly how to do this.

    i'll write an example of what i'm trying to achieve here:


    List X Contents (what i'm trying to display in this specific list are specific entries only related to the players inventory, and to get rid of anything else that isn't relevant to this specific list)
    meat=7
    wooden shield=3
    iron sword=2

    with that said, here is the INI file contents of the main INI i'm pulling from to load into the list that i want to populate)

    [char1]
    position blah blah blah
    direction blah blah blah
    [location]
    frame=3
    [inventory]
    meat=7
    wooden shield=3
    iron sword=2
    [party]
    char1=john
    char2=shirley
    etc


    how could i tell the list to search for the contents of [Inventory] and the elements afterwards without getting extra stuff like the whole [party] section or anything before [inventory]?

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Posts
    1,299
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    If you're using INI, you'd have to do something silly like this:

    [inventory]
    NoItems=3
    Item0=Meat
    NumOf0=7
    Item1=Shield
    NumOf1=3
    Item2=Sword
    NumOf2=2

    To be honest, people use INI way too much. It's good for storing small amounts of data in a file that is intended to be edited by the end user, and needs to be human-readable, but that's it - otherwise (including in this case) you'd be better off using an array or other storage object.

  3. #3
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2012
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the problem i have (and many others) have with arrays is that they are much more difficult to use in terms of displaying data to the end user, or by using the data internally.

    oh, what's that? you have value [13,26] marked as a 3? what is that value storing referring to? who knows unless you have a giant spreadsheet... and it gets even worse when trying to call this information to either use it, or to display it. where was the value i assigned to determine whether the drawbridge was opened or closed for a characters quest to continue?

    it's very frustrating using arrays sometimes to display both text and data, which an INI handles much easier for me as a developer. if there's another type of object other than an array to display both text and/or data to a user easily like an ini can, or for me to be able to make a quick balance change without having to dig through miles of code searching for something when i could have just opened an ini file and did a simple control F search for whatever i was modifying, i'm all ears.

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree, ini is more user friendly than arrays, though arrays are much more easily controlled.

    You can do this easy with ini++ without changing the item naming, ini++ has actions to list every item from a group and simliar, but with normal ini you have to do a what muddymole said or similiar.

    For instance what i would do without changing the item names, if you have an object representing each possible item in the frame, run a foreach loop and check their string if it exists in that group and retrieve the amount if > 0.

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2012
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i also don't think you understand what I asked for MuddyMole - no offense

    i have a bunch of other data included with what you listed, and i don't want that populating the list i wish to use for testing purposes. please reread what i asked. this isn't for how to deal with data, this is merely a question on how to only display within a list, specific contents from a file.

  6. #6
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2012
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    skyhunter - i don't need to do this. i know what you're thinking of, but this is just text. the items in my game, are not objects. they are merely text, with values.

    all i want to know is if it is possible to take some specific data from an INI file (a section, if you will), and load it into a list for display purposes. i used to know how to do such a thing with a tokenizer, but i'm afraid i don't remember anymore now.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah you want to see the content of the ini during runtime?, you could load the ini into the string parser and add delimiter [inventory] and [party] and retrieve element 2. which would then give you everything from the inventory in a single string, you can then display it with editbox easily(just tick multiline and scrollbar).

    Also make sure you load the ini file normally with load from file instead of load from ini which crashes mmf

    If you really want each line in the list object instead:

    then add newline$ as a delimiter to get further substrings based on each line in ini and start a loop count of elements times

    on loop retrieve elements and add them to list with the loopindex.

  8. #8
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2012
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    skyhunter - this is exactly what i wanted to do

    do you have an example similar to what you are describing? i looked at the documentation for string parser 2, but it didn't include any examples of how or where to use the delimiter in code, or to set source string, or what i have to do to actually set it up and make it functionable.

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  10. #10
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2012
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks!

Similar Threads

  1. Showcase Section ?
    By BHGames in forum SWF/Flash Export Module Version 2.0
    Replies: 3
    Last Post: 31st March 2011, 05:20 PM
  2. I know this is the wrong section but please help!!
    By csj1 in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 26th July 2008, 04:18 AM
  3. specific animation has played a specific frame?
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 15
    Last Post: 22nd April 2008, 04:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •