There are some almost new metric functions. They'll tell you the bonus for each metric, but not the underlying measurement. The release that's now in devprev is supposed to allow graduated metrics, so the bonus can be proportionate to the measurement. Right now in main, it's either 1000 points or not for each metric. (The puzzle needs to be set up correctly to return these graduated bonuses.)
Check out the metric functions on the Foldit Lua Functions page.
The function metric.GetNames() returns a Lua table containing the names of metrics for the current puzzle. If the table is empty, there are no metrics. The code looks something like:
metz = metric.GetNames ()
if #metz == 0 then
print ( "no metrics found" )
else
for ii = 1, #metz do
print ( "metric " .. ii .. " = \"" .. metz [ ii ] .. "\", score = " .. metric.GetBonus ( metz [ ii ] ) )
end
end
There are two score-related functions, metric.GetBonus and metric.GetBonusTotal. GetBonus gets the bonus for one specified metric. Assuming you have the code above, the for loop could include the bonus:
for ii = 1, #metz do
print ( "metric " .. ii .. " = \"" .. metz [ ii ] .. "\", score = " .. metric.GetBonus ( metz [ ii ] ) )
end
The function metric.GetBonusTotal returns the total of all metrics.
The "metric" functions don't include the enable/disable functions you'll find under "filter". Instead, the function behavior.SetFiltersDisabled can be used to disable or enable all metrics and filters. With filters, recipes can disable or enable individual filters, but this isn't possible for metrics.
Unlike filters, metrics return a score (bonus) even when they're disabled. Calling "metric.GetBonus ( "DDG Metric" )" will return the bonus (if any) even when the metric is disabled. The call also appears to recalculate the metric, so it may be on the slow side.
The wiki page condition and metric control gets into the issue of enabling and disabling filters and metrics. It's a whole can of worms. Basically the idea is that you want to disable stuff for performance reasons, but then you want to enable again to make sure you don't miss out on something good. Especially for recipes, figuring out when you want to enable filters and metrics is strategically important.