sorcery  crafttools.lua at [65759dbfde]

File crafttools.lua artifact 569141ccf4 part of check-in 65759dbfde


minetest.register_on_craft(function(stack,crafter,recipe,grid)
	local ctoolclass = {
		[1] = 200;
		[2] = 100;
		[3] = 50;
		[4] = 10;
		[5] = 5;
	}
	for i=1,grid:get_size('craft') do
		local s = grid:get_stack('craft',i)
		local v = minetest.get_item_group(s:get_name(),'crafttool')
		if v ~= 0 then
			local dmg = 65536 / ctoolclass[v]
			local tool = recipe[i] 
			tool:add_wear(dmg)
			grid:set_stack('craft',i,tool)
		end
	end
	return nil
end)

if minetest.get_modpath('xdecor') then
	local og = minetest.registered_tools['xdecor:hammer'].groups
	og.crafttool = 2
	minetest.override_item('xdecor:hammer', {groups = og})
end

minetest.register_tool('sorcery:vice', {
	description = 'Vice';
	inventory_image = 'sorcery_vice.png';
	group = { crafttool = 3; }
})
minetest.register_craft {
	output = 'sorcery:vice';
	recipe = {
		{'default:steel_ingot','sorcery:screw_steel','default:steel_ingot'};
		{'default:bronze_ingot','sorcery:screw_steel','default:bronze_ingot'};
		{'default:tin_ingot','default:tin_ingot','default:tin_ingot'};
	};
}
-- chisel