Show repairing recipes in craft guide
This commit is contained in:
parent
3bb5ab67d6
commit
ea583a2d70
|
@ -2,10 +2,34 @@ mcl_craftguide = {}
|
|||
|
||||
local craftguide, datas, mt = {}, {}, minetest
|
||||
local progressive_mode = mt.setting_getbool("craftguide_progressive_mode")
|
||||
local get_recipe, get_recipes = mt.get_craft_recipe, mt.get_all_craft_recipes
|
||||
local get_recipe = mt.get_craft_recipe
|
||||
local get_result, show_formspec = mt.get_craft_result, mt.show_formspec
|
||||
local reg_items = mt.registered_items
|
||||
|
||||
local get_recipes = function(query_item)
|
||||
local recipes = mt.get_all_craft_recipes(query_item)
|
||||
|
||||
-- Manually add repairing recipes (workaround, because get_all_craft_recipes
|
||||
-- doesn't return repairing recipes)
|
||||
if minetest.get_modpath("mcl_core") then
|
||||
local def = minetest.registered_items[query_item]
|
||||
if def.type == "tool" then
|
||||
if recipes == nil then
|
||||
recipes = {}
|
||||
end
|
||||
table.insert(recipes, {
|
||||
type = "normal",
|
||||
width = 0,
|
||||
items = { [1] = query_item, [2] = query_item },
|
||||
output = query_item,
|
||||
-- Special marker for repairing recipes
|
||||
_is_toolrepair = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
return recipes
|
||||
end
|
||||
|
||||
-- Lua 5.3 removed `table.maxn`, use this alternative in case of breakage:
|
||||
-- https://github.com/kilbith/xdecor/blob/master/handlers/helpers.lua#L1
|
||||
local remove, maxn, sort = table.remove, table.maxn, table.sort
|
||||
|
@ -127,7 +151,7 @@ function craftguide:get_recipe(iY, xoffset, tooltip, item, recipe_num, recipes)
|
|||
elseif is_shapeless then
|
||||
formspec = formspec..
|
||||
"image["..(xoffset-0.8)..","..(iY+1)..
|
||||
".5;0.5,0.5;craftguide_shapeless.png]"
|
||||
".5;0.5,0.5;craftguide_shapeless.png]"
|
||||
end
|
||||
|
||||
local rows = ceil(maxn(items) / width)
|
||||
|
@ -302,8 +326,9 @@ function craftguide:get_init_items()
|
|||
local items_list, counter = {}, 0
|
||||
for name, def in pairs(reg_items) do
|
||||
local is_fuel = get_fueltime(name) > 0
|
||||
local is_tool = def.type == "tool"
|
||||
if (not def.groups.not_in_craft_guide or def.groups.not_in_craft_guide == 0)
|
||||
and (get_recipe(name).items or is_fuel)
|
||||
and (get_recipe(name).items or is_fuel or is_tool)
|
||||
and def.description and def.description ~= "" then
|
||||
counter = counter + 1
|
||||
items_list[counter] = name
|
||||
|
@ -403,6 +428,7 @@ mt.register_on_player_receive_fields(function(player, formname, fields)
|
|||
data.item = item
|
||||
data.recipe_num = 1
|
||||
data.recipes_item = recipes
|
||||
|
||||
craftguide:get_formspec(player_name, is_fuel)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ minetest.register_tool("mcl_throwing:bow_0", {
|
|||
description = "Bow",
|
||||
inventory_image = "mcl_throwing_bow_0.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:replace("mcl_throwing:bow_1")
|
||||
|
@ -81,7 +81,7 @@ minetest.register_tool("mcl_throwing:bow_1", {
|
|||
description = "Bow",
|
||||
inventory_image = "mcl_throwing_bow_1.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:replace("mcl_throwing:bow_2")
|
||||
|
@ -104,7 +104,7 @@ minetest.register_tool("mcl_throwing:bow_2", {
|
|||
description = "Bow",
|
||||
inventory_image = "mcl_throwing_bow_2.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:replace("mcl_throwing:bow")
|
||||
|
|
Loading…
Reference in New Issue
Block a user