mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-26 04:23: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()`
|
||||||
|
25
init.lua
25
init.lua
@ -63,10 +63,10 @@ craftguide.register_craft_type("digging", {
|
|||||||
|
|
||||||
function craftguide.register_craft(def)
|
function craftguide.register_craft(def)
|
||||||
local func = "craftguide." .. __func() .. "(): "
|
local func = "craftguide." .. __func() .. "(): "
|
||||||
assert(def.type, func .. "'type' field missing")
|
assert(def.type, func .. "'type' field missing")
|
||||||
assert(def.width, func .. "'width' field missing")
|
assert(def.width, func .. "'width' field missing")
|
||||||
assert(def.output, func .. "'output' field missing")
|
assert(def.output, func .. "'output' field missing")
|
||||||
assert(def.items, func .. "'items' field missing")
|
assert(def.items, func .. "'items' field missing")
|
||||||
|
|
||||||
craftguide.custom_crafts[#craftguide.custom_crafts + 1] = def
|
craftguide.custom_crafts[#craftguide.custom_crafts + 1] = def
|
||||||
end
|
end
|
||||||
@ -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