add copy crafting recipie
This commit is contained in:
parent
48e265aae7
commit
827766a92f
39
init.lua
39
init.lua
@ -383,3 +383,42 @@ minetest.register_craft({
|
||||
{"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "waypoint_compass:compass",
|
||||
recipe = {"waypoint_compass:compass", "waypoint_compass:compass"}
|
||||
})
|
||||
|
||||
local function waypoint_compass_copy_meta(itemstack, player, old_craft_grid, craft_inv)
|
||||
if itemstack:get_name() ~= "waypoint_compass:compass" then
|
||||
return
|
||||
end
|
||||
|
||||
local original
|
||||
local index
|
||||
for i = 1, #old_craft_grid do
|
||||
local meta = old_craft_grid[i]:get_meta()
|
||||
if get_compass_meta_is_set(meta) then
|
||||
if not original then
|
||||
original = old_craft_grid[i]
|
||||
index = i
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
end
|
||||
if not original then
|
||||
return ""
|
||||
end
|
||||
local copymeta = original:get_meta():to_table()
|
||||
itemstack:get_meta():from_table(copymeta)
|
||||
-- put the compass with metadata back in the craft grid
|
||||
craft_inv:set_stack("craft", index, original)
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_craft(waypoint_compass_copy_meta)
|
||||
|
||||
minetest.register_craft_predict(waypoint_compass_copy_meta)
|
||||
|
Loading…
Reference in New Issue
Block a user