Split value in config ini file onto multiple lines

edited November 2011 in Help request
Hi, is there any way to split a configuration file value onto multiple lines for organization and readability?

For example, this wants to make me jump off a mountain:
AnimationList = NessIdleLeft#NessWalkLeft#NessIdleRight#NessWalkRight#NessIdleUp#NessWalkUp#NessIdleDown#NessWalkDown
LinkList = NessILL#NessIL-WL#NessWLL#NessWL-IL#NessIL-IR#NessIL-IU#NessIRL#NessIR-WR#NessWRL#NessWR-IR#NessIR-IL#NessIR-ID#NessIUL#NessIU-WU#NessWUL#NessWU-IU#NessIU-IR#NessIDL#NessID-WD#NessWDL#NessWD-ID#NessID-IL

Whereas something like this would make it easier to split the linked list into organizational units and comment them.
AnimationList = NessIdleLeft#NessWalkLeft#NessIdleRight#NessWalkRight#NessIdleUp#NessWalkUp#NessIdleDown#NessWalkDown
LinkList =
   NessILL#NessIL-WL#NessWLL#NessWL-IL#NessIL-IR#NessIL-IU# ; Left behaviors
   NessIRL#NessIR-WR#NessWRL#NessWR-IR#NessIR-IL#NessIR-ID# ; Right behaviors
   NessIUL#NessIU-WU#NessWUL#NessWU-IU#NessIU-IR# ; Up behaviors
   NessIDL#NessID-WD#NessWDL#NessWD-ID#NessID-IL ; Down behaviors

Thanks!

Comments

  • edited November 2011
    Split lines used to be supported as orx was always looking for a ';' to finish a value. That proved to be very troublesome as many people preferred to omit that ';'. So now a value stops automatically at the carriage return.
    There's still a way to input multi-lines values, using "none", but this doesn't support lists, only single values.

    So I'm afraid not! I could add a character to manually specify a value isn't finished, like in C, I guess. I need to think more about it though.
  • edited November 2011
    Thanks! It's not an enormous problem for me, but it does make the above scenario (managing a large AnimSet) difficult to debug. Something like an escape character in C would be great.
  • edited November 2011
    I too met the same problem, so a change in this direction will be very appreciated. :)
  • edited November 2011
    I'll try to do something this way then, but really not sure when it'll happen! I'll let you know when it's done. :)
  • edited November 2011
    I was thinking about it some more today and I thought another way to achieve this might be to support something like a += operator for linked lists.

    If this were possible, there would be a couple more added benefits.

    You could add comments at the end of each line for organization.

    This would also allow for a config section that inherits from another section to copy and extend the linked list defined in the parent section, rather than merely overwriting it. I found myself wanting to do this once the other day.

    I don't know if this aligns with your vision of the config system, but just an idea!
  • edited November 2011
    Ideally that'd be nice.
    However, this can't really be used for extending a list through inheritance as inheritance is dynamic and simply a reference.
    When a value is inherited, there's no local copy of it, it simply references its parent allowing for on-the-fly inheritance changes, no matter how deep the inheritance graph is.
    If a local copy were to be made (and extended), that'd mean a few things:
    - everytime a parent value is changed, all the children need to be reprocessed. We don't know who the children are so we'd need to store that info and reprocess the whole dependency graph of a node every time a value is changed, added or removed.
    - everytime an inheritance dependency is changed, we'd also need to reprocess everything (deleting a section, changing its parent, ...)
    Worse: the indexing (ie. the size of the list) can drastically change and become invalid if a parent's list size change at runtime.

    As for the comments at the end of the line, I can allow them after the escape character.

    As for your specific case, can you tell me in which case you needed to extend a list by inheritance, if you don't mind?

    When I need a dynamic list, in some case (like a list of objects) I'd go with a property tag instead and build the list at runtime. An other option is too have a list of list or even patching list elements programmatically when loading your game for example.
  • edited November 2011
    I to was eventually going to ask about breaking lines for the animation lists.

    I don't have any ideas though. Sorry.

    I get around it simply by putting my cursor to the line below and using the left arrow once.
  • edited November 2011
    I have to admit I'm simply using the text wrap feature of text editors but I can see why this feature would be nice.
    The way we declare animations is the most annoying piece of config one has to write and I couldn't come with a better way to define them in config. Any suggestion?
  • edited November 2011
    Hmmm actually, I did wonder one if it was possible to construct inherited lists in the same manner as the objects, graphics ie:

    AnimationListLeft = #IdleLeft#WalkLeft#JumpLeft#SwimLeft
    AnimationListRight = #IdleRight#WalkRight#JumpRight#SwimRight
    AnimationList = #AnimationListLeft#AnimationListRight

    Just a rough thought, but something along those lines.
  • edited November 2011
    If you wish to do this kind of organization yourself, you can support it on the user side with only a couple of lines of code: before creating any animation, you can go through the list of lists and add all the items to your list that you will then store in config to replace AnimationList.
  • edited December 2011
    My two cents,

    I think if a list that includes a line ends with a #, then it is unambiguously not finished, therefore the next line can be safely assumed to be a continuation. Very similar to the use of quotation marks for multi-line strings.

    This would require an edit to the config file parser, but it should be reasonably straightforward.

    What do you think?
  • edited December 2011
    Sounds like a very reasonable solution to me, considering it'll probably satisfy 99% of the cases. My only slight concern is for people who actually want to put an empty string value at the end of their list. That wouldn't work anymore.
  • edited December 2011
    Wouldn't something like

    MyList = Blah#Blah2#"none"

    work for that?
  • edited December 2011
    duenez wrote:
    My two cents,

    I think if a list that includes a line ends with a #, then it is unambiguously not finished, therefore the next line can be safely assumed to be a continuation. Very similar to the use of quotation marks for multi-line strings.

    This would require an edit to the config file parser, but it should be reasonably straightforward.

    What do you think?

    I really like this suggestion.
  • edited December 2011
    duenez wrote:
    Wouldn't something like

    MyList = Blah#Blah2#"none"

    work for that?
    Not really, unfortunately.

    List1 = Item1 # "none" # apple contains 3 strings: Item1, "none", apple.
    List2 = Item1 # # apple contains 3 strings: Item1, <empty_string>, apple.
  • edited December 2011
    I guess wanting an empty string at the end of a list is a rare enough occurrence that a special case would be acceptable?

    Something like: List = Item1 # Item2 ##
  • edited December 2011
    That was what I was going to suggest. That looks good to me.
  • edited December 2011
    Sorry for the long delay but I couldn't find the time to implement this feature earlier.

    If you sync the SVN, lists can now span multiple lines and line ending comments are allowed.

    Here's the small description I added at the beginning of the template files:
    ; Lists can contain random values.
    ; Example:
    ; Key1 = Var1 # Var2 # RandVar3 ~ RandVar4 # Var5;
    ; Lists can span multiple lines when using # at the end of the line (line ending comments are allowed).
    ; If you want to define an empty element at the end of a list, use ##
    ; Example:
    ; Key2 = Var1 # Var2 #
    ;        Var3 #; This list still continues on next line and this comment is valid.
    ;        Var4  ; This list is now complete and contains 4 elements.
    ; Key3 = Var1 # Var2 ##; This list will not span on the next line but will content a 3rd (and last) empty element.
    

    Let me know if this works for you or if you encounter weird issues: after all, orx's config parser is a bit complex and I wouldn't be too surprised if I broke something! ;)
  • edited December 2011
    That's great. I'm now getting back to an Orx project after a couple weeks off and will try it out.

    This will really help for those complex lists.
  • edited January 2012
    Glad to help. Let me know if there's any issue with them.
  • edited January 2012
    Much better. It's great to be able to comment a section of a list without terminating it.

    And blank lines seem not to terminate the list either, so you can split your list into groups.
  • edited January 2012
    I'm glad you like it.

    And I totally forgot to mention the trimming of white spaces, which also include CR, LF and tab.
Sign In or Register to comment.