Fade out uncraftable recipes and a few other bugfixes
This commit is contained in:
parent
1faf15b5cf
commit
04040b5e2e
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
|
--
|
||||||
-- API
|
-- API
|
||||||
|
--
|
||||||
|
|
||||||
crafting = {}
|
crafting = {}
|
||||||
|
|
||||||
@ -46,8 +48,10 @@ function crafting.register_craft(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, crafting.max_inputs do
|
for i = 1, crafting.max_inputs do
|
||||||
|
if craftdef.items[i] ~= nil then
|
||||||
craftdef.items[i] = ItemStack(craftdef.items[i])
|
craftdef.items[i] = ItemStack(craftdef.items[i])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
crafting.registered_crafts[itemkey] = craftdef
|
crafting.registered_crafts[itemkey] = craftdef
|
||||||
|
|
||||||
@ -217,7 +221,7 @@ form = form .. default.ui.button(7.25, 1.25, 1, 1, "do_craft_1", "1")
|
|||||||
form = form .. default.ui.button(7.25, 2.25, 1, 1, "do_craft_10", "10")
|
form = form .. default.ui.button(7.25, 2.25, 1, 1, "do_craft_10", "10")
|
||||||
|
|
||||||
form = form .. "tableoptions[background=#DDDDDD30]"
|
form = form .. "tableoptions[background=#DDDDDD30]"
|
||||||
form = form .. "tablecolumns[text,align=left,width=2;text,align=left,width=40]"
|
form = form .. "tablecolumns[color,span=2;text,align=left,width=2;text,align=left,width=40]"
|
||||||
|
|
||||||
default.ui.register_page("crafting:crafting", form)
|
default.ui.register_page("crafting:crafting", form)
|
||||||
|
|
||||||
@ -228,6 +232,8 @@ function crafting.get_formspec(name)
|
|||||||
row = crafting.userdata[name].row
|
row = crafting.userdata[name].row
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local inv = minetest.get_player_by_name(name):get_inventory()
|
||||||
|
|
||||||
local craft_list = ""
|
local craft_list = ""
|
||||||
|
|
||||||
local craftitems = crafting.get_crafts(nil)
|
local craftitems = crafting.get_crafts(nil)
|
||||||
@ -243,10 +249,47 @@ function crafting.get_formspec(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if itemdef ~= nil then
|
if itemdef ~= nil then
|
||||||
|
local craftdef = crafting.registered_crafts[itemn]
|
||||||
|
|
||||||
if craft_list ~= "" then
|
if craft_list ~= "" then
|
||||||
craft_list = craft_list .. ","
|
craft_list = craft_list .. ","
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local color = "#fff"
|
||||||
|
|
||||||
|
for i = 1, crafting.max_inputs do
|
||||||
|
if craftdef.items[i] ~= nil then
|
||||||
|
local group = string.match(craftdef.items[i]:get_name(), "group:(.*)")
|
||||||
|
|
||||||
|
if group ~= nil then
|
||||||
|
local check_itemstack = ItemStack(craftdef.items[i])
|
||||||
|
|
||||||
|
color = "#bbb"
|
||||||
|
|
||||||
|
for itemn, _ in pairs(minetest.registered_items) do
|
||||||
|
if minetest.get_item_group(itemn, group) ~= 0
|
||||||
|
and minetest.get_item_group(itemn, "not_in_craftingguide") ~= 1 then
|
||||||
|
check_itemstack:set_name(itemn)
|
||||||
|
|
||||||
|
if inv:contains_item("main", check_itemstack) then
|
||||||
|
color = "#fff"
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if not inv:contains_item("main", craftdef.items[i]) then
|
||||||
|
color = "#bbb"
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
craft_list = craft_list .. color .. ","
|
||||||
|
|
||||||
if itemstack:get_count() ~= 1 then
|
if itemstack:get_count() ~= 1 then
|
||||||
craft_list = craft_list .. minetest.formspec_escape(itemstack:get_count())
|
craft_list = craft_list .. minetest.formspec_escape(itemstack:get_count())
|
||||||
end
|
end
|
||||||
@ -277,7 +320,7 @@ function crafting.get_formspec(name)
|
|||||||
form = form .. default.ui.fake_itemstack_any(
|
form = form .. default.ui.fake_itemstack_any(
|
||||||
1.25, 3.25, selected_craftdef.items[4], "craftex_in_4")
|
1.25, 3.25, selected_craftdef.items[4], "craftex_in_4")
|
||||||
end
|
end
|
||||||
if selected_craftdef.items[4] ~= nil then
|
if selected_craftdef.output ~= nil then
|
||||||
form = form .. default.ui.fake_itemstack_any(
|
form = form .. default.ui.fake_itemstack_any(
|
||||||
7.25, 0.25, selected_craftdef.output, "craftex_out")
|
7.25, 0.25, selected_craftdef.output, "craftex_out")
|
||||||
end
|
end
|
||||||
|
@ -402,8 +402,8 @@ crafting.register_craft(
|
|||||||
output = "default:fence 4",
|
output = "default:fence 4",
|
||||||
items = {
|
items = {
|
||||||
"default:planks",
|
"default:planks",
|
||||||
"default:stick 4",
|
|
||||||
"default:fiber 4",
|
"default:fiber 4",
|
||||||
|
"default:stick 4",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ default.ui.default.bg = "bgcolor[#00000000;false]"
|
|||||||
-- Group default items
|
-- Group default items
|
||||||
|
|
||||||
default.ui.group_defaults = {
|
default.ui.group_defaults = {
|
||||||
|
fuzzy = "mobs:wool",
|
||||||
planks = "default:planks",
|
planks = "default:planks",
|
||||||
soil = "default:dirt",
|
soil = "default:dirt",
|
||||||
stone = "default:stone",
|
stone = "default:stone",
|
||||||
|
Loading…
Reference in New Issue
Block a user