-
June 13th, 2023, 22:04 #1
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>
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...
-
June 13th, 2023, 23:56 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,668
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>
Code:state = { [1] = { icon = { [1] = "buttonicon", }, }, [2] = { icon = { [1] = "buttonicon_down", }, }, }
JPG
-
June 14th, 2023, 04:49 #3
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