lua.wetgenes.gamecake.fun.yarn.rules
rules = require("wetgenes.gamecake.fun.yarn.rules").create(items)
This module contains only one function which can be used to create an rules instance and the rest of this documentation concerns the return from this create function, not the module itself.
lua.wetgenes.gamecake.fun.yarn.rules.apply
item = rules.apply(item,method,...)
item.rules must be a list of rule names and the order in which they should be applied to this item.
Call the given method in each rule with the item and the remaining arguments.
If the method returns a value then no more methods will be applied even if more rules are listed.
We always return the passed in item so that calls can be chained.
item = item:apply(method,...)
This function is inserted into the items.metatable so it can be called directly from an item.
lua.wetgenes.gamecake.fun.yarn.rules.can
yes = rules.can(item,method)
Returns true if any rule in this item has the given method.
yes = item:can(method)
This function is inserted into the items.metatable so it can be called directly from an item.
lua.wetgenes.gamecake.fun.yarn.rules.set
rule = rules.set(rule)
Set this base rule into the name space using rule.name which must be a string.
Multiple rules can be applied to an item and each rule will be applied in the order listed.
A rule is a table of named functions that can be applied to an item.
rule.setup(item)
Must setup the item so that it is safe to call the other rules on it.
rule.clean(item)
Should cleanup anything that needs cleaning.
rule.tick(item)
Should perform a single time tick update on the item.