Compare commits
5 Commits
e8042462c3
...
fefcd5a316
Author | SHA1 | Date |
---|---|---|
Oversword | fefcd5a316 | |
Oversword | 58e09ed48d | |
Oversword | 516b035345 | |
Oversword | d5a1b58a82 | |
Oversword | c6c62b1ddc |
|
@ -45,58 +45,95 @@ function stairsplus:prepare_groups(groups)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
local function recipe_registered_to_register(existing_recipe)
|
||||||
|
local recipe_obj = {
|
||||||
|
output = existing_recipe.output,
|
||||||
|
}
|
||||||
|
if existing_recipe.type == "normal" and existing_recipe.width == 0 then
|
||||||
|
recipe_obj.type = "shapeless"
|
||||||
|
recipe_obj.recipe = existing_recipe.items
|
||||||
|
elseif existing_recipe.type == "cooking" then
|
||||||
|
recipe_obj.type = "cooking"
|
||||||
|
recipe_obj.recipe = existing_recipe.items[1]
|
||||||
|
elseif existing_recipe.type == "normal" then
|
||||||
|
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
|
||||||
|
else
|
||||||
|
minetest.log("error", "Crafting type not accounted for, tell Oversword: "..dump(existing_recipe))
|
||||||
|
end
|
||||||
|
return recipe_obj
|
||||||
|
end
|
||||||
|
|
||||||
function stairsplus:register_all(modname, subname, recipeitem, fields, stairs_subname)
|
function stairsplus:register_all(modname, subname, recipeitem, fields, stairs_subname)
|
||||||
|
|
||||||
if not stairs_subname then stairs_subname = subname end
|
if not stairs_subname then stairs_subname = subname end
|
||||||
-- This could be distributed amongst the various sub-calls, but we almost always use register_all so this works
|
-- 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 stairs_items = {
|
local possible_stairs_items = {
|
||||||
["stairs:stair_" .. stairs_subname] = modname .. ":stair_" .. subname,
|
["stairs:stair_" .. stairs_subname] = modname .. ":stair_" .. subname,
|
||||||
["stairs:stair_outer_" .. stairs_subname] = modname .. ":stair_" .. subname .. "_outer",
|
["stairs:stair_outer_" .. stairs_subname] = modname .. ":stair_" .. subname .. "_outer",
|
||||||
["stairs:stair_inner_" .. stairs_subname] = modname .. ":stair_" .. subname .. "_inner",
|
["stairs:stair_inner_" .. stairs_subname] = modname .. ":stair_" .. subname .. "_inner",
|
||||||
["stairs:slab_" .. stairs_subname] = modname .. ":slab_" .. subname
|
["stairs:slab_" .. stairs_subname] = modname .. ":slab_" .. subname
|
||||||
}
|
}
|
||||||
|
local cleanup_stairs = false
|
||||||
for stair_item, _ in pairs(stairs_items) do
|
local stairs_items = {}
|
||||||
minetest.clear_craft({ output=stair_item })
|
local original_def = minetest.registered_nodes[recipeitem]
|
||||||
end
|
local original_tile = original_def and get_tile(original_def)
|
||||||
|
if original_tile then
|
||||||
local existing_recipes = minetest.get_all_craft_recipes(recipeitem)
|
for stair_item,alias in pairs(possible_stairs_items) do
|
||||||
|
local def = minetest.registered_nodes[stair_item]
|
||||||
if existing_recipes then
|
if def and (
|
||||||
local standard_recipes = {}
|
original_def.mod_origin == def.mod_origin or
|
||||||
for i,existing_recipe in pairs(existing_recipes) do
|
original_tile == get_tile(def)
|
||||||
if existing_recipe.type == "normal" then
|
) then
|
||||||
local standard = false
|
stairs_items[stair_item] = alias
|
||||||
for _,item in pairs(existing_recipe.items) do
|
cleanup_stairs = true
|
||||||
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
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.clear_craft({ output=recipeitem })
|
if cleanup_stairs then
|
||||||
for _,recipe in pairs(standard_recipes) do
|
for stair_item, _ in pairs(stairs_items) do
|
||||||
minetest.register_craft(recipe)
|
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
|
||||||
|
table.insert(standard_recipes, recipe_registered_to_register(existing_recipe))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(standard_recipes, recipe_registered_to_register(existing_recipe))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.clear_craft({ output=recipeitem })
|
||||||
|
for _,recipe in pairs(standard_recipes) do
|
||||||
|
minetest.register_craft(recipe)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,8 +143,10 @@ function stairsplus:register_all(modname, subname, recipeitem, fields, stairs_su
|
||||||
self:register_panel(modname, subname, recipeitem, fields)
|
self:register_panel(modname, subname, recipeitem, fields)
|
||||||
self:register_micro(modname, subname, recipeitem, fields)
|
self:register_micro(modname, subname, recipeitem, fields)
|
||||||
|
|
||||||
for stair_item, alias in pairs(stairs_items) do
|
if cleanup_stairs then
|
||||||
minetest.register_alias_force(stair_item, alias)
|
for stair_item, alias in pairs(stairs_items) do
|
||||||
|
minetest.register_alias_force(stair_item, alias)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue