Merge pull request #4 from oversword/stairs_conflicts
Remove stairs conflicting crafts before registering stairsplus craftsmaster
commit
516b035345
|
@ -45,12 +45,98 @@ function stairsplus:prepare_groups(groups)
|
|||
return result
|
||||
end
|
||||
|
||||
function stairsplus:register_all(modname, subname, recipeitem, fields)
|
||||
local function get_tile(node_def, index)
|
||||
if not index then index = 1 end
|
||||
return
|
||||
((node_def.tiles and node_def.tiles[index] and
|
||||
(node_def.tiles[index].name or node_def.tiles[index]))
|
||||
or (node_def.tile_images and node_def.tile_images[index]))
|
||||
end
|
||||
|
||||
function stairsplus:register_all(modname, subname, recipeitem, fields, stairs_subname)
|
||||
|
||||
if not stairs_subname then stairs_subname = subname end
|
||||
-- This could be distributed amongst the various sub-calls, or put in register-single, but we almost always use register_all so this works
|
||||
local possible_stairs_items = {
|
||||
["stairs:stair_" .. stairs_subname] = modname .. ":stair_" .. subname,
|
||||
["stairs:stair_outer_" .. stairs_subname] = modname .. ":stair_" .. subname .. "_outer",
|
||||
["stairs:stair_inner_" .. stairs_subname] = modname .. ":stair_" .. subname .. "_inner",
|
||||
["stairs:slab_" .. stairs_subname] = modname .. ":slab_" .. subname
|
||||
}
|
||||
local cleanup_stairs = false
|
||||
local stairs_items = {}
|
||||
local original_def = minetest.registered_nodes[recipeitem]
|
||||
local original_tile = original_def and get_tile(original_def)
|
||||
if original_tile then
|
||||
for stair_item,alias in pairs(possible_stairs_items) do
|
||||
local def = minetest.registered_nodes[stair_item]
|
||||
if def and (
|
||||
original_def.mod_origin == def.mod_origin or
|
||||
original_tile == get_tile(def)
|
||||
) then
|
||||
stairs_items[stair_item] = alias
|
||||
cleanup_stairs = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if cleanup_stairs then
|
||||
for stair_item, _ in pairs(stairs_items) do
|
||||
minetest.clear_craft({ output=stair_item })
|
||||
end
|
||||
|
||||
local existing_recipes = minetest.get_all_craft_recipes(recipeitem)
|
||||
|
||||
if existing_recipes then
|
||||
local standard_recipes = {}
|
||||
for i,existing_recipe in pairs(existing_recipes) do
|
||||
if existing_recipe.type == "normal" then
|
||||
local standard = false
|
||||
for _,item in pairs(existing_recipe.items) do
|
||||
if not stairs_items[item] then
|
||||
standard = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if standard then
|
||||
local recipe_obj = {
|
||||
output = existing_recipe.output,
|
||||
}
|
||||
if existing_recipe.width == 0 then
|
||||
recipe_obj.type = "shapeless"
|
||||
recipe_obj.recipe = existing_recipe.items
|
||||
else
|
||||
recipe_obj.recipe = {{},{},{}}
|
||||
for x=1,3 do
|
||||
for y=1,existing_recipe.width do
|
||||
local p = ((x-1)*existing_recipe.width)+y
|
||||
recipe_obj.recipe[x][y] = existing_recipe.items[p] or ""
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(standard_recipes, recipe_obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.clear_craft({ output=recipeitem })
|
||||
for _,recipe in pairs(standard_recipes) do
|
||||
minetest.register_craft(recipe)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self:register_stair(modname, subname, recipeitem, fields)
|
||||
self:register_slab(modname, subname, recipeitem, fields)
|
||||
self:register_slope(modname, subname, recipeitem, fields)
|
||||
self:register_panel(modname, subname, recipeitem, fields)
|
||||
self:register_micro(modname, subname, recipeitem, fields)
|
||||
|
||||
if cleanup_stairs then
|
||||
for stair_item, alias in pairs(stairs_items) do
|
||||
minetest.register_alias_force(stair_item, alias)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function stairsplus:register_alias_all(modname_old, subname_old, modname_new, subname_new)
|
||||
|
|
|
@ -380,12 +380,6 @@ stairsplus.register_recipes = function(category, alternate, modname, subname, re
|
|||
output = modname .. ":stair_" .. subname,
|
||||
recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = modname .. ":stair_" .. subname,
|
||||
recipe = {modname .. ":panel_" .. subname, modname .. ":panel_" .. subname, modname .. ":panel_" .. subname},
|
||||
})
|
||||
elseif alternate == "_inner" then
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
|
|
|
@ -68,13 +68,7 @@ for _, name in pairs(default_nodes) do
|
|||
ndef.tiles = {ndef.tiles[1]}
|
||||
ndef.paramtype2 = nil
|
||||
end
|
||||
|
||||
mod = "moreblocks"
|
||||
stairsplus:register_all(mod, name, nodename, ndef)
|
||||
minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name)
|
||||
minetest.register_alias_force("stairs:stair_outer_" .. name, mod .. ":stair_" .. name .. "_outer")
|
||||
minetest.register_alias_force("stairs:stair_inner_" .. name, mod .. ":stair_" .. name .. "_inner")
|
||||
minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name)
|
||||
stairsplus:register_all("moreblocks", name, nodename, ndef)
|
||||
end
|
||||
|
||||
-- farming registrations
|
||||
|
@ -86,12 +80,7 @@ if minetest.get_modpath("farming") then
|
|||
local ndef = table.copy(minetest.registered_nodes[nodename])
|
||||
ndef.sunlight_propagates = true
|
||||
|
||||
mod = "moreblocks"
|
||||
stairsplus:register_all(mod, name, nodename, ndef)
|
||||
minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name)
|
||||
minetest.register_alias_force("stairs:stair_outer_" .. name, mod .. ":stair_" .. name .. "_outer")
|
||||
minetest.register_alias_force("stairs:stair_inner_" .. name, mod .. ":stair_" .. name .. "_inner")
|
||||
minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name)
|
||||
stairsplus:register_all("moreblocks", name, nodename, ndef)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue