1 --Quick definition of hoes
2 local material = {"wood","stone","iron","gold","diamond"}
3 local construct = {"wood","cobble","iron","gold","diamond"}
4 local function till_soil(pos)
5 local nodey = minetest.get_node(pos).name
6 local is_dirt = (nodey == "main:dirt" or nodey == "main:grass")
8 minetest.sound_play("dirt",{pos=pos})
9 minetest.set_node(pos,{name="farming:farmland_dry"})
14 for level,material in pairs(material) do
15 local wear = 100*(6-level)
17 if material == "wood" then
19 dirt = {times={[1]=0.4,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
20 snow = {times={[1]=0.4,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
21 grass = {times={[1]=0.45,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
22 sand = {times={[1]=0.4,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
25 elseif material == "stone" then
27 dirt = {times={[1]=0.2,[2]=0.2,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
28 snow = {times={[1]=0.2,[2]=0.2,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
29 grass = {times={[1]=0.25,[2]=0.25,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
30 sand = {times={[1]=0.2,[2]=0.2,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
33 elseif material == "iron" then
35 dirt = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
36 snow = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
37 grass = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
38 sand = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
41 elseif material == "gold" then
43 dirt = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
44 snow = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
45 grass = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
46 sand = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
49 elseif material == "diamond" then
51 dirt = {times={[1]= 0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=1561, maxlevel=1},
52 snow = {times={[1]= 0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=1561, maxlevel=1},
53 grass = {times={[1]= 0.15,[2]=0.15,[3]=0.15,[4]=0.15,[5]=1.5}, uses=1561, maxlevel=1},
54 sand = {times={[1]= 0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=1561, maxlevel=1},
58 minetest.register_tool("farming:"..material.."hoe", {
59 description = material:gsub("^%l", string.upper).." Hoe",
60 inventory_image = material.."hoe.png",
62 --full_punch_interval = 1.2,
65 damage_groups = {damage=damage},
67 sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
68 groups = {flammable = 2, tool=1 },
70 on_place = function(itemstack, placer, pointed_thing)
71 local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
72 local sneak = placer:get_player_control().sneak
74 if not sneak and noddef.on_rightclick then
75 minetest.item_place(itemstack, placer, pointed_thing)
79 local tilled = till_soil(pointed_thing.under)
80 if tilled == true then
81 if minetest.registered_nodes[minetest.get_node(vector.new(pointed_thing.under.x,pointed_thing.under.y+1,pointed_thing.under.z)).name].buildable_to then
82 minetest.dig_node(vector.new(pointed_thing.under.x,pointed_thing.under.y+1,pointed_thing.under.z))
84 itemstack:add_wear(wear)
87 local damage = itemstack:get_wear()
88 if damage <= 0 and tilled == true then
89 minetest.sound_play("tool_break",{object=placer})
94 minetest.register_craft({
95 output = "farming:"..material.."hoe",
97 {"","main:"..construct[level], "main:"..construct[level]},
98 {"","main:stick", ""},
99 {"", "main:stick", ""}
102 minetest.register_craft({
103 output = "farming:"..material.."hoe",
105 {"main:"..construct[level],"main:"..construct[level], ""},
106 {"","main:stick", ""},
107 {"", "main:stick", ""}