predicate.ash: general purpose predicate expression evaluator

predicate 1.0

What is it?
A general purpose predicate expression evaluator.

A predicate is a string expression that evaluates to true or false. Examples:
primestat<29,ascensions>0,outfit=cloaca-cola uniform,quest=fernswarthy's tower
or
item=dingy dinghy,equip=pirate fledges|outfit=swashbuckling getup,property(warProgress)!started

Note: Depends on zarqon's excellent zlib.ash and my log_lib.ash and pageCache.ash make sure you install them first.

For Users

No end user serviceable parts.

For Script Authors

Predicate can operate in one of three modes. "is" mode just checks to see if the predicate is currently true. "could" mode sees if the predicate could be made to be true. "doit" mode checks to see if the predicate could be made to be true, and if so does whatever is needed.

predicate currently considers equipping items, unequipping items, using items, or changing familiars. It knows which items give what effects, and what items are in outfits (so it can check if you are actually wearing an outfit.) It does not consider eating, drinking, using spleen items, or anything that would use an adventure.

Uses pageCache to reduce the number of server hits.

Methods

boolean predicate(string condition, string mode)
mode is one of "is", "could", or "doit"

Predicate Syntax
A predicate is a comma separated list of terms that must all be true. Each term is a "|" separated list of tests, one of which must be true. A test is an identifier possibly with a parameter, followed by an operator "=", "!", "<", or ">", and ending with a value string.

Legal tests are:

adventures
Number of adventures remaining.

ascensions
Number of times you've ascended.

inebriety_left
How much more you can drink without being drunk.

effect
If you have the named effect.

elemental_resistance
If you have resistance to the named element.

equip
If you have the named item equipped.

familiar
If you have the named familiar as your current familiar.

holiday
If today is the named holiday.

item
If you have the named item.

my_raidlog
If your character has a line with the named string in your clan raid log.

primestat
Your unbuffed prime stat.

outfit
If you are currently wearing the named outfit.

property(param)
If the property parameter has the named value.

quest
Abbreviation for quest_complete|quest_current.

quest_complete
If you have completed the named quest. (If your completed quests page contains the named text.)

quest_current
If you are currently on the named quest (If your current quests page contains the named text.)

quest_other
If your other quests page contains the named text.

sign
If you ascended under the named sign.

special
Always true, prints value as informational message (log_info)

url(param)
If the url parameter contains the named text.

Issues

Does not visit council or guild to get or complete quests.


Change Log
1.0 2009/11/18 Initial release
 

Attachments

  • predicate.ash
    15.1 KB · Views: 118

Theraze

Active member
Just a note, since it was asked about. The two e.to_effect() calls need to be changed to a straight e, since e is already an effect and otherwise you're doing $effect[].to_effect() which is just sad laziness.
 
Top