Crafting guide : simplify group to node determination
This commit is contained in:
parent
9b95401a36
commit
f2d17916a2
2
hive.lua
2
hive.lua
@ -39,7 +39,7 @@ xdecor.register("hive", {
|
|||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"xdecor:hive"},
|
nodenames = {"xdecor:hive"},
|
||||||
interval = 20, chance = 10,
|
interval = 30, chance = 10,
|
||||||
action = function(pos, _, _, _)
|
action = function(pos, _, _, _)
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
local honeystack = inv:get_stack("honey", 1)
|
local honeystack = inv:get_stack("honey", 1)
|
||||||
|
@ -122,39 +122,20 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
|
|||||||
for k, def in pairs(stack_items) do
|
for k, def in pairs(stack_items) do
|
||||||
craft[#craft+1] = def
|
craft[#craft+1] = def
|
||||||
if def and def:find("^group:") then
|
if def and def:find("^group:") then
|
||||||
if def:find("wool") then
|
if def:find("wool$") then
|
||||||
def = "wool:white"
|
def = "wool:white"
|
||||||
elseif def:find("dye") then
|
elseif def:find("dye$") then
|
||||||
local dye_color = def:match(".*_([%w_]+)")
|
def = "dye:white"
|
||||||
def = "dye:"..dye_color
|
|
||||||
elseif def:find("flower") then
|
|
||||||
local flower_color = def:match(".*_([%w_]+)")
|
|
||||||
if flower_color == "red" then
|
|
||||||
def = "flowers:rose"
|
|
||||||
elseif flower_color == "yellow" then
|
|
||||||
def = "flowers:dandelion_yellow"
|
|
||||||
elseif flower_color == "white" then
|
|
||||||
def = "flowers:dandelion_white"
|
|
||||||
elseif flower_color == "blue" then
|
|
||||||
def = "flowers:geranium"
|
|
||||||
elseif flower_color == "orange" then
|
|
||||||
def = "flowers:tulip"
|
|
||||||
elseif flower_color == "violet" then
|
|
||||||
def = "flowers:viola"
|
|
||||||
elseif def:find("^group:flower$") then
|
|
||||||
def = "flowers:rose"
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
|
if minetest.registered_items["default:"..def:match("^group:([%w_]+)$")] then
|
||||||
def = def:gsub("group", "default")
|
def = def:gsub("group", "default")
|
||||||
else
|
else
|
||||||
for node, definition in pairs(minetest.registered_items) do
|
for node, definition in pairs(minetest.registered_items) do
|
||||||
for group in pairs(definition.groups) do
|
for group in pairs(definition.groups) do
|
||||||
if def:match("^group:"..group) then
|
if def:match("^group:"..group.."$") or
|
||||||
if inv:get_stack("craft_output_recipe", k):is_empty() or
|
((def:find("dye") or def:find("flower")) and
|
||||||
node:find("^default:") then
|
group == def:match("^group:.*,("..group..")")) then
|
||||||
inv:set_stack("craft_output_recipe", k, node)
|
def = node
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -162,9 +143,7 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not def:find("^group:") then
|
inv:set_stack("craft_output_recipe", k, def)
|
||||||
inv:set_stack("craft_output_recipe", k, def)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
formspec = formspec..[[ image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]
|
formspec = formspec..[[ image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]
|
||||||
|
Loading…
Reference in New Issue
Block a user