Re-introduce the progressive mode! YESSSSS
This commit is contained in:
parent
e26f03f37e
commit
d25e9ec4cc
6 changed files with 40 additions and 36 deletions
|
@ -5,7 +5,7 @@
|
||||||
#### Registering a custom crafting type (example)
|
#### Registering a custom crafting type (example)
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
craftguide.register_craft_type("digging", {
|
mcl_craftguide.register_craft_type("digging", {
|
||||||
description = "Digging",
|
description = "Digging",
|
||||||
icon = "default_tool_steelpick.png",
|
icon = "default_tool_steelpick.png",
|
||||||
})
|
})
|
||||||
|
@ -14,7 +14,7 @@ craftguide.register_craft_type("digging", {
|
||||||
#### Registering a custom crafting recipe (example)
|
#### Registering a custom crafting recipe (example)
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
craftguide.register_craft({
|
mcl_craftguide.register_craft({
|
||||||
type = "digging",
|
type = "digging",
|
||||||
width = 1,
|
width = 1,
|
||||||
output = "default:cobble 2",
|
output = "default:cobble 2",
|
||||||
|
@ -29,7 +29,7 @@ craftguide.register_craft({
|
||||||
Recipe filters can be used to filter the recipes shown to players. Progressive
|
Recipe filters can be used to filter the recipes shown to players. Progressive
|
||||||
mode is implemented as a recipe filter.
|
mode is implemented as a recipe filter.
|
||||||
|
|
||||||
#### `craftguide.add_recipe_filter(name, function(recipes, player))`
|
#### `mcl_craftguide.add_recipe_filter(name, function(recipes, player))`
|
||||||
|
|
||||||
Adds a recipe filter with the given name. The filter function should return the
|
Adds a recipe filter with the given name. The filter function should return the
|
||||||
recipes to be displayed, given the available recipes and an `ObjectRef` to the
|
recipes to be displayed, given the available recipes and an `ObjectRef` to the
|
||||||
|
@ -39,7 +39,7 @@ user. Each recipe is a table of the form returned by
|
||||||
Example function to hide recipes for items from a mod called "secretstuff":
|
Example function to hide recipes for items from a mod called "secretstuff":
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
craftguide.add_recipe_filter("Hide secretstuff", function(recipes)
|
mcl_craftguide.add_recipe_filter("Hide secretstuff", function(recipes)
|
||||||
local filtered = {}
|
local filtered = {}
|
||||||
for _, recipe in ipairs(recipes) do
|
for _, recipe in ipairs(recipes) do
|
||||||
if recipe.output:sub(1,12) ~= "secretstuff:" then
|
if recipe.output:sub(1,12) ~= "secretstuff:" then
|
||||||
|
@ -51,15 +51,15 @@ craftguide.add_recipe_filter("Hide secretstuff", function(recipes)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `craftguide.remove_recipe_filter(name)`
|
#### `mcl_craftguide.remove_recipe_filter(name)`
|
||||||
|
|
||||||
Removes the recipe filter with the given name.
|
Removes the recipe filter with the given name.
|
||||||
|
|
||||||
#### `craftguide.set_recipe_filter(name, function(recipe, player))`
|
#### `mcl_craftguide.set_recipe_filter(name, function(recipe, player))`
|
||||||
|
|
||||||
Removes all recipe filters and adds a new one.
|
Removes all recipe filters and adds a new one.
|
||||||
|
|
||||||
#### `craftguide.get_recipe_filters()`
|
#### `mcl_craftguide.get_recipe_filters()`
|
||||||
|
|
||||||
Returns a map of recipe filters, indexed by name.
|
Returns a map of recipe filters, indexed by name.
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ Notes:
|
||||||
- Filters can be combined.
|
- Filters can be combined.
|
||||||
- The `groups` filter is currently implemented by default.
|
- The `groups` filter is currently implemented by default.
|
||||||
|
|
||||||
#### `craftguide.add_search_filter(name, function(item, values))`
|
#### `mcl_craftguide.add_search_filter(name, function(item, values))`
|
||||||
|
|
||||||
Adds a search filter with the given name.
|
Adds a search filter with the given name.
|
||||||
The search function should return a boolean value (whether the given item should be listed or not).
|
The search function should return a boolean value (whether the given item should be listed or not).
|
||||||
|
@ -88,7 +88,7 @@ The search function should return a boolean value (whether the given item should
|
||||||
Example function to show items which contain at least a recipe of given width(s):
|
Example function to show items which contain at least a recipe of given width(s):
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
craftguide.add_search_filter("widths", function(item, widths)
|
mcl_craftguide.add_search_filter("widths", function(item, widths)
|
||||||
local has_width
|
local has_width
|
||||||
local recipes = recipes_cache[item]
|
local recipes = recipes_cache[item]
|
||||||
|
|
||||||
|
@ -109,11 +109,11 @@ craftguide.add_search_filter("widths", function(item, widths)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `craftguide.remove_search_filter(name)`
|
#### `mcl_craftguide.remove_search_filter(name)`
|
||||||
|
|
||||||
Removes the search filter with the given name.
|
Removes the search filter with the given name.
|
||||||
|
|
||||||
#### `craftguide.get_search_filters()`
|
#### `mcl_craftguide.get_search_filters()`
|
||||||
|
|
||||||
Returns a map of search filters, indexed by name.
|
Returns a map of search filters, indexed by name.
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ Returns a map of search filters, indexed by name.
|
||||||
|
|
||||||
### Custom formspec elements
|
### Custom formspec elements
|
||||||
|
|
||||||
#### `craftguide.add_formspec_element(name, def)`
|
#### `mcl_craftguide.add_formspec_element(name, def)`
|
||||||
|
|
||||||
Adds a formspec element to the current formspec.
|
Adds a formspec element to the current formspec.
|
||||||
Supported types: `box`, `label`, `image`, `button`, `tooltip`, `item_image`, `image_button`, `item_image_button`
|
Supported types: `box`, `label`, `image`, `button`, `tooltip`, `item_image`, `image_button`, `item_image_button`
|
||||||
|
@ -129,7 +129,7 @@ Supported types: `box`, `label`, `image`, `button`, `tooltip`, `item_image`, `im
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
craftguide.add_formspec_element("export", {
|
mcl_craftguide.add_formspec_element("export", {
|
||||||
type = "button",
|
type = "button",
|
||||||
element = function(data)
|
element = function(data)
|
||||||
-- Should return a table of parameters according to the formspec element type.
|
-- Should return a table of parameters according to the formspec element type.
|
||||||
|
@ -152,11 +152,11 @@ craftguide.add_formspec_element("export", {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `craftguide.remove_formspec_element(name)`
|
#### `mcl_craftguide.remove_formspec_element(name)`
|
||||||
|
|
||||||
Removes the formspec element with the given name.
|
Removes the formspec element with the given name.
|
||||||
|
|
||||||
#### `craftguide.get_formspec_elements()`
|
#### `mcl_craftguide.get_formspec_elements()`
|
||||||
|
|
||||||
Returns a map of formspec elements, indexed by name.
|
Returns a map of formspec elements, indexed by name.
|
||||||
|
|
||||||
|
@ -164,10 +164,8 @@ Returns a map of formspec elements, indexed by name.
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
#### `craftguide.show(player_name, item, show_usages)`
|
#### `mcl_craftguide.show(player_name, item, show_usages)`
|
||||||
|
|
||||||
Opens the Crafting Guide with the current filter applied.
|
Opens the Crafting Guide with the current filter applied.
|
||||||
|
|
||||||
* `player_name`: string param.
|
* `player_name`: string param.
|
||||||
* `item`: optional, string param. If set, this item is pre-selected. If the item does not exist or has no recipe, use the player's previous selection. By default, player's previous selection is used
|
|
||||||
* `show_usages`: optional, boolean param. If true, show item usages.
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ local recipes_cache = {}
|
||||||
local usages_cache = {}
|
local usages_cache = {}
|
||||||
local fuel_cache = {}
|
local fuel_cache = {}
|
||||||
|
|
||||||
local progressive_mode = M.settings:get_bool("craftguide_progressive_mode") and rawget(_G, "sfinv")
|
local progressive_mode = M.settings:get_bool("mcl_craftguide_progressive_mode") or true
|
||||||
local sfinv_only = M.settings:get_bool("craftguide_sfinv_only") and rawget(_G, "sfinv")
|
local sfinv_only = false
|
||||||
|
|
||||||
local colorize = M.colorize
|
local colorize = M.colorize
|
||||||
local reg_items = M.registered_items
|
local reg_items = M.registered_items
|
||||||
|
@ -1008,6 +1008,8 @@ else
|
||||||
M.register_on_player_receive_fields(function(player, formname, fields)
|
M.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname == "mcl_craftguide" then
|
if formname == "mcl_craftguide" then
|
||||||
on_receive_fields(player, fields)
|
on_receive_fields(player, fields)
|
||||||
|
elseif fields.__mcl_craftguide then
|
||||||
|
mcl_craftguide.show(player:get_player_name())
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -1129,7 +1131,7 @@ if progressive_mode then
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_craftguide.show(name, item, show_usages)
|
function mcl_craftguide.show_old(name, item, show_usages)
|
||||||
local func = "mcl_craftguide.show(): "
|
local func = "mcl_craftguide.show(): "
|
||||||
assert(name, func .. "player name missing")
|
assert(name, func .. "player name missing")
|
||||||
|
|
||||||
|
@ -1148,6 +1150,16 @@ function mcl_craftguide.show(name, item, show_usages)
|
||||||
show_fs(player, name)
|
show_fs(player, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_craftguide.show(name)
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if next(recipe_filters) then
|
||||||
|
local data = player_data[name]
|
||||||
|
data.items_raw = get_filtered_items(player)
|
||||||
|
search(data)
|
||||||
|
end
|
||||||
|
show_formspec(name, "mcl_craftguide", make_formspec(name))
|
||||||
|
end
|
||||||
|
|
||||||
--[[ Custom recipes (>3x3) test code
|
--[[ Custom recipes (>3x3) test code
|
||||||
|
|
||||||
M.register_craftitem(":secretstuff:custom_recipe_test", {
|
M.register_craftitem(":secretstuff:custom_recipe_test", {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
# If enabled, the recipe book will progressively be filled with new recipes that can be crafted from all items you ever have had in your inventory.
|
||||||
craftguide_progressive_mode (Progressive Mode) bool false
|
# Recommended for new players and for a spoiler-free gameplay experience.
|
||||||
|
# If disabled, all recipes will be shown.
|
||||||
# Integration in the default Minetest Game inventory.
|
mcl_craftguide_progressive_mode (Learn crafting recipes progressively) bool true
|
||||||
craftguide_sfinv_only (Sfinv only) bool false
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
mcl_init
|
mcl_init
|
||||||
mcl_player?
|
mcl_player?
|
||||||
mcl_craftguide?
|
|
||||||
_mcl_autogroup?
|
_mcl_autogroup?
|
||||||
3d_armor?
|
3d_armor?
|
||||||
|
|
|
@ -131,8 +131,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if not minetest.settings:get_bool("creative_mode") and (formname == "" or formname == "main") then
|
if not minetest.settings:get_bool("creative_mode") and (formname == "" or formname == "main") then
|
||||||
set_inventory(player)
|
set_inventory(player)
|
||||||
end
|
end
|
||||||
elseif fields.__mcl_craftguide and mod_craftguide then
|
|
||||||
mcl_craftguide.show(player:get_player_name())
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,11 @@ mcl_keepInventory (Keep inventory on death) bool false
|
||||||
# If enabled, chat messages are shown to everyone when a player dies.
|
# If enabled, chat messages are shown to everyone when a player dies.
|
||||||
mcl_showDeathMessages (Show death messages) bool true
|
mcl_showDeathMessages (Show death messages) bool true
|
||||||
|
|
||||||
|
# If enabled, the recipe book will progressively be filled with new recipes that can be crafted from all items you ever have had in your inventory.
|
||||||
|
# Recommended for new players and for a spoiler-free gameplay experience.
|
||||||
|
# If disabled, all recipes will be shown.
|
||||||
|
mcl_craftguide_progressive_mode (Learn crafting recipes progressively) bool true
|
||||||
|
|
||||||
[Mobs]
|
[Mobs]
|
||||||
# If enabled, mobs will spawn naturally. This does not affect
|
# If enabled, mobs will spawn naturally. This does not affect
|
||||||
# affect mob spawners.
|
# affect mob spawners.
|
||||||
|
@ -74,13 +79,6 @@ mobs_disable_blood (Disable mob blood) bool false
|
||||||
flame_sound (Flame sound) bool true
|
flame_sound (Flame sound) bool true
|
||||||
|
|
||||||
[Experimental]
|
[Experimental]
|
||||||
# If enabled, the recipe book will only show recipes which require one
|
|
||||||
# item which you have already discovered.
|
|
||||||
# If disabled, the recipe book shows all crafting recipes.
|
|
||||||
# This setting is EXPERIMENTAL and may be changed in later versions.
|
|
||||||
# Feedback is appreciated.
|
|
||||||
craftguide_progressive_mode (Enable recipe book progressive mode) bool false
|
|
||||||
|
|
||||||
# Mobs difficulty. This is a number that will affect the initial and maximum
|
# Mobs difficulty. This is a number that will affect the initial and maximum
|
||||||
# health and the amount of damage that mobs deal. Health and damage will
|
# health and the amount of damage that mobs deal. Health and damage will
|
||||||
# be multiplied with this number.
|
# be multiplied with this number.
|
||||||
|
|
Reference in a new issue