My favorites | Sign in
Project Home Downloads Wiki Issues
Search
for
RuleFunction  
Rule Functions
Updated Apr 7, 2010 by arkaye...@gmail.com

Rule Functions

General

rule formulas essentially equate to either true or false depending on the functions and arguments you give. false means an item didn't match, true means it did and will be assigned to that rule.

the default formula starts out as false, you don't need to keep that in your own rule formula, it's just a place holder so that a "blank" rule can be saved but wont match any item.

don't forget that there are system categories for the basic stuff, ie trash, skills, class, etc, which you can specifically assign an item to, so you shouldn't create a rule for the basic stuff unless you have a very specific reason.

when creating a rule formula, try to keep it as simple and short as possible, eg;

type( "armor" ) and subtype( "cloth" ) or subtype( "leather" ) or subtype( "mail" )

this does 3 separate calls to the subtype function. you should always try and compress any same function or comparisons down to a single function call where possible. eg;

type( "armor" ) and subtype( "cloth","leather","mail" )

this would be quicker (although that particular function is pretty fast anyway), but some functions, like outfit( ), are fairly intensive so calling them as little as possible is good.

Basics

  • function names are case sensitive, they need to be lowercase
  • the Lua logic operators and, or, not need to be in lowercase
  • the arguments passed to a function are normally case insensitive (converted to lower case for matching purposes), unless that function specifically requires an exact case match (eg periodictable)
  • leading and trailing spaces are trimmed from all arguments
  • code changes can cause a rule to become "damaged", it that happens it will be flagged as damaged and will not be used until it is corrected and resaved
  • where a rule takes multiple arguments it functions as an explicit or. eg name( "scroll", "elixir", "potion" ) is equivalent to name( "scroll" ) or name( "elixir" ) or name( "potion" )

Functions

Example Rules

Some example rules can be found here

Powered by Google Project Hosting