5E Product Walkthrough Playlist
  1. #1
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075

    Accessing XML Parameters from Scripts

    This section always confused me - I sometimes get "dense" with things and have to revaluate it later. I did so, several times for a minute or 3 over a long time, everytime I came across this. I so very rarely used the indexing and when I did, I simply bruteforced it if I got it wrong until it was right. But I wanted to always "grok" it.
    https://fantasygroundsunity.atlassia...s-from-Scripts

    I recenty USED the [1]/[2] on my own in a script correctly and remembered to check again. This time, I still didn't get why "empy" & "normal" were treated so differently than "first" & "last". So, fed up with my denseness - I did what I always do, setup a test app. In this case the code I was working on, I added a simple control to and looked at the output:

    Code:
    <genericcontrol>
      <states>
        <empty>
          <icon>emptyicon</icon>
        </empty>
        <normal>
          <icon>normalicon</icon>
        </normal>
      </states>
      <flags>
        <first />
        <second />
      </flags>
      <label>Control label</label>
      <script>
    	function onInit()
    		Debug.console(states)
    		Debug.console(flags)
    		Debug.console(label)
    	end
      </script>
    </genericcontrol>
    And the result:
    controlindex.JPG

    So, it seems my confusion was because for all these years that wiki page was in error? There IS no [2] to be seen, I couldn't figure out what there would be...

  2. #2
    I've fixed the example on that page to match the example tags.

    The additional indexes will only appear if multiple tags with the same name are defined.

    For example:
    Code:
      <buttoncontrol>
        <state><icon>buttonicon</icon</state>
        <state><icon>buttonicon_down</frame></state>
        <script>
    	function onInit()
    		Debug.console(state)
    	end
        </script>
      </buttoncontrol>
    would return:
    Code:
    state = {
      [1] = {
        icon = {
          [1] = "buttonicon",
        },
      },
      [2] = {
        icon = {
          [1] = "buttonicon_down",
        },
      },
    }
    Regards,
    JPG

  3. #3
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Cool that is exactly how I thought I understood it, the point of the array, but the example always vexxed me. Glad I finally gave up reading it and tried it.
    Basically, I hadn't USED repeating groups until I worked on a template recently and that's when I remembered to go back and look at it again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Log in

Log in