mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-23 03:13:44 +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))`
|
#### `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.
|
The default `craftguide` progressive filter will be overridden.
|
||||||
|
|
||||||
#### `craftguide.get_progressive_filters()`
|
#### `craftguide.get_progressive_filters()`
|
||||||
|
21
init.lua
21
init.lua
@ -570,14 +570,23 @@ local function progressive_default_filter(recipes, player)
|
|||||||
return filtered
|
return filtered
|
||||||
end
|
end
|
||||||
|
|
||||||
local progressive_filters = {progressive_default_filter}
|
local progressive_filters = {{
|
||||||
|
name = "Default filter",
|
||||||
|
func = progressive_default_filter,
|
||||||
|
}}
|
||||||
|
|
||||||
function craftguide.add_progressive_filter(func)
|
function craftguide.add_progressive_filter(name, func)
|
||||||
progressive_filters[#progressive_filters + 1] = func
|
progressive_filters[#progressive_filters + 1] = {
|
||||||
|
name = name,
|
||||||
|
func = func,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function craftguide.set_progressive_filter(func)
|
function craftguide.set_progressive_filter(name, func)
|
||||||
progressive_filters = {func}
|
progressive_filters = {{
|
||||||
|
name = name,
|
||||||
|
func = func,
|
||||||
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
function craftguide.get_progressive_filters()
|
function craftguide.get_progressive_filters()
|
||||||
@ -586,7 +595,7 @@ end
|
|||||||
|
|
||||||
local function apply_progressive_filters(recipes, player)
|
local function apply_progressive_filters(recipes, player)
|
||||||
for i = 1, #progressive_filters do
|
for i = 1, #progressive_filters do
|
||||||
local func = progressive_filters[i]
|
local func = progressive_filters[i].func
|
||||||
recipes = func(recipes, player)
|
recipes = func(recipes, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user