mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-12-13 18:20:17 +01:00
Progressive mode: Add a name to filters
This commit is contained in:
parent
61ae85a09c
commit
5ee1bea4ce
@ -66,7 +66,7 @@ end)
|
||||
|
||||
#### `craftguide.set_progressive_filter(function(recipes, player))`
|
||||
|
||||
This function sets an unique recipes filter when progressive mode is enabled.
|
||||
This function sets an unique recipe filter when progressive mode is enabled.
|
||||
The default `craftguide` progressive filter will be overridden.
|
||||
|
||||
#### `craftguide.get_progressive_filters()`
|
||||
|
21
init.lua
21
init.lua
@ -570,14 +570,23 @@ local function progressive_default_filter(recipes, player)
|
||||
return filtered
|
||||
end
|
||||
|
||||
local progressive_filters = {progressive_default_filter}
|
||||
local progressive_filters = {{
|
||||
name = "Default filter",
|
||||
func = progressive_default_filter,
|
||||
}}
|
||||
|
||||
function craftguide.add_progressive_filter(func)
|
||||
progressive_filters[#progressive_filters + 1] = func
|
||||
function craftguide.add_progressive_filter(name, func)
|
||||
progressive_filters[#progressive_filters + 1] = {
|
||||
name = name,
|
||||
func = func,
|
||||
}
|
||||
end
|
||||
|
||||
function craftguide.set_progressive_filter(func)
|
||||
progressive_filters = {func}
|
||||
function craftguide.set_progressive_filter(name, func)
|
||||
progressive_filters = {{
|
||||
name = name,
|
||||
func = func,
|
||||
}}
|
||||
end
|
||||
|
||||
function craftguide.get_progressive_filters()
|
||||
@ -586,7 +595,7 @@ end
|
||||
|
||||
local function apply_progressive_filters(recipes, player)
|
||||
for i = 1, #progressive_filters do
|
||||
local func = progressive_filters[i]
|
||||
local func = progressive_filters[i].func
|
||||
recipes = func(recipes, player)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user