How To: Use Property Tests

Discussion in 'XmlSpawner Development' started by Chris, Jun 17, 2014.

  1. Chris

    Chris Renaissance Staff
    Renaissance Staff

    Joined:
    May 14, 2012
    Messages:
    3,385
    Likes Received:
    6,195
    Property tests are used in several places, including the

    1) the 'property test' field in XmlFind
    2) the Condition field in XmlDialogs
    3) with IF, WAITUNTIL, and WHILE keywords in spawn entries,
    4) with triggering property test strings on the spawner such as TriggerObjectProp, PlayerTriggerProp, and the MobTriggerProp.
    5) optional arguments to the different quest type keywords such as KILL, GIVE, etc.

    In general, the property tests follow the same syntax

    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'
    - 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'
    - 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>

    - 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.​


    Original Document by ArteGordon - Modified for use on UO:Renaissance
    Original Article - http://xmlspawner.fr.yuku.com/topic/399#.U6B3rZTiKy4

Share This Page