Full Version : XMLFind & Property test's
xmlspawner >>Q&A >>XMLFind & Property test's
<< Prev | Next >>
godfood- 03-20-2006
I've had some trouble getting this to work properly, sometimes I can figure it out, othertimes I can't .
Could you do a little write up on this Arte?
sabray1- 04-20-2006
This is just the topic I was looking for. Wish there was a document on it.
ArteGordon- 04-20-2006
yeah, I can add a write up on that.
Are there specific examples that are giving you problems?
In general, the property tests follow the same syntax as the conditional test used in xmlspawners and in XmlDialogs.
The basic form of the tests is
[~]<value><operator><value>
where 'value' can either be the name of a property on the object, a number or string, or a keyword that returns a value such as RND or GETONSPAWN.
The operators are one of <>!=, where
< is less than
> is greater than
! is not equal
= is equal
and you can put the optional NOT modifier '~' in front of the test to invert the results.
So for example, to find things with weight greater than 10, use a test like
weight > 10
while the test
~weight > 10
would find things that do NOT have weight greater than 10
Note that it doesnt matter if you place spaces between the values and the operator, and the property name is not case sensitive so you dont have to worry about getting any capitalization right.
Some values have special formatting requirements such as '#' in front of an enum value, like
loottype = #Blessed
to test the loottype property which is a LootType enum (note that the enum value IS case sensitive so 'Blessed' is correct while 'blessed' is not).
or timespans that have to have the format 'hours:min:sec'

QUOTE
- added support for timespan properties in conditional tests. For example, in [xmlfind, using the property test of "mindelay>0:10:00" along with the type of "xmlspawner" will search for all xmlspawners with a mindelay of more that 10 mins.

or datetimes that have to take the form 'mo/day/yr'

QUOTE
- added support for datetime properties in conditional tests. For example, in [xmlfind, using the property test of "lastmodified>6\15\2005" along with the type of "xmlspawner" will search for all xmlspawners that were modified since 6\15\2005, or "lastmodified>6\15\2005 3:30 pm" will find those modified since 3:30 in the afternoon of 6\15\2005.

You can also compose compound tests by using the &| operators between multiple tests like
<value><operator><value> & <value><operator><value>

QUOTE
- added the and (&) and or (|) operators to allow compound conditional tests of the form "a=b & c<d", "e<f | g!h". These can be extended arbitrarily, i.e. "a*b $ c*d $ e*f $ g*h ..." , where * is one of <>!= and $ is one of &|, but the current default grouping precedence is not exactly intuitive.
Default grouping follows this rule "(a*b $ (c*d $ (e*f $ g*h)))" where, due to parsing efficiency, conditional pairs at the end of an
expression are tested first and then recursively work their way back to the beginning.
An example of using this feature is given in chestguardian2.xml in xmlextras.
In this example the guardian spawner is triggered by the property test (TriggerObjectProp) "totalitems<1 | totalweight<20" which will lead to triggering of the chest guardian if anyone removes the pile of gold from the chest completely (leaving totalitems=0), or removes some of the gold, (reducing the totalweight to below 20).
Another example is given in chestguardian3.xml in xmlextras.
In this example the guardian spawner is triggered by the property test (TriggerObjectProp) "totalitems>1 & totalweight>40" which will lead to triggering of the chest guardian if at least one additional item is added (totalitems>1), and the added items weigh enough to push the totalweight above 40.