-
-
Notifications
You must be signed in to change notification settings - Fork 41
Ruleset API
Bagnon and Combuctor allow you to create custom rulesets.
As rulesets are managed through a shared API in Wildpants, registering a rule in one addon is exactly the same as on the other. You can even make a plugin that supports both addons, if you just check first which one is being used:
local Addon = Bagnon or Combuctor
In the remainder of the page, consider Addon
to correspond to either one.
Registers a new ruleset with the given id
. If id
is already registered, this will update the registered rule with the new parameters provided. Errors if id
is not a string.
Addon.Rules:New('myrule', 'My Ruleset', 'bananas.tga', function(player, bag, slot, bagInfo, itemInfo)
return itemInfo.link == bananaLink
end)
Rulesets can also be hierarchized into subsets. This is done through the rule id
in a similar fashion to web URLs. However, to register a subset, the parent subset must already be registered:
-- works
Addon.Rules:New('myrule/subset', 'My Subset', 'single_banana.tga', function(player, bag, slot, bagInfo, itemInfo)
return itemInfo.id == bananaID and itemInfo.count == 1
end)
-- will error
Addon.Rules:New('unknownrule/subset', 'My Subset', 'single_banana.tga', function(player, bag, slot, bagInfo, itemInfo)
return slot == 2 and itemInfo.count > 1
end)
Returns a data structure with all the information pertaining the requested ruleset and its subsets.
If the ruleset is not registered, return nil.
In our example case, requesting myrule
would return:
{
id = 'myrule',
name = 'My Ruleset',
icon = 'bananas.tga',
func = @firstFunction
children = {
{
id = 'myrule/subset',
name = 'My Subset',
icon = 'single_banana.tga',
func = @secondFunction,
children = {}
}
}
}
Returns an iterator over all registered rules. In our example case, this would include both My Ruleset and My Subset.
Usage example:
for id, rule in Addon.Rules:Iterate() do
print(rule.name .. ' is registered!')
end
Similar to the previous method. Returns an iterator over all registered rules at the top level of the hierarchy. In our example case, this would only include My Ruleset.
This is the Wildpants wiki. Wiki Home
For Users
FAQ
Existing Plugins
Search Syntax
For Developers
Ruleset API
Custom Events
Sorting Items