reanjr
First Post
Firzair said:Hi reanjr,
I think there is some more functionality needed from the RPGL:
- Some kind of SELECT for getting a collection of something used with a kind of FOREACH clause (e.g. Select from Feats where Feats.Type like "Fighter").
- I think there has to be a scope for each function (e.g. something that says this function belongs to the object creature)
Could this already be done or do you have to implement some more tags?
Greetings
Firzair
As to the first point, there is a way to do it (and I suppose it could be mashed into a function, too; but I hadn't gotten to anything like that yet). Basically, the <a> function can resolve simple XPath like statements and return arrays of data. For instance:
<a>feats.feat:type='Fighter'</a>
Would return an array of all feat elements that are children of the feats element and half a type attribute set to Fighter. Once you have this array, you can use another special resolution mechanism ::
Say that you store the array in a variable called fighter-feats. Then:
<a>fighter-feats::count</a>
Would return the number of elements in the array
<a>fighter-feats::1</a>
Would return the first of them.
So you could fairly easily write a foreach function (and I'm pretty sure I will).
I haven't finalized anything on the way those variable resolutions work yet, but tentatively, the following apply:
Code:
.
Current context
.child
The child of the current context (and so forth like .child.grandchild etc.) This can be a child element or a property of the context.
:property
A property. If this is left without any qualification, it just checks if the property exists or not. You can also append ='value' to evaluate to a property that is set to a particular value. I use single quotes here for ease of parsing. Unlike using the .child syntax to select a property, using the :property syntax doesn't evaluate to the property but is used as a means of identifying elements. (I hope I explained that clearly, I can't tell).
::count
The number of elements in the reference. Usually 1.
::1, ::2, etc.
A particular element if there are multiple. Defaults to the first element if unspecified.
[ ]
Anything found in brackets is evaluated as a variable reference then plugged in to its surroundings (<a>fighter-feats::[counter]</a> for instance).