1
0
Fork 0
VoxeLibre-WolfyCode/mods/ITEMS/mcl_farming/hoes.lua

283 lines
8.5 KiB
Lua
Raw Normal View History

local S = minetest.get_translator("mcl_farming")
local function create_soil(pos, inv)
2015-06-29 19:55:56 +02:00
if pos == nil then
return false
end
2017-01-05 01:28:43 +01:00
local node = minetest.get_node(pos)
2015-06-29 19:55:56 +02:00
local name = node.name
2017-01-05 01:28:43 +01:00
local above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
2017-01-10 04:01:53 +01:00
if minetest.get_item_group(name, "cultivatable") == 2 then
2015-06-29 19:55:56 +02:00
if above.name == "air" then
2017-01-31 12:35:59 +01:00
node.name = "mcl_farming:soil"
2017-01-05 01:28:43 +01:00
minetest.set_node(pos, node)
2017-03-12 02:03:45 +01:00
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.5 })
2017-01-05 01:28:43 +01:00
return true
end
2017-01-10 04:01:53 +01:00
elseif minetest.get_item_group(name, "cultivatable") == 1 then
2017-01-05 01:28:43 +01:00
if above.name == "air" then
2017-01-31 23:32:56 +01:00
node.name = "mcl_core:dirt"
2017-01-05 01:28:43 +01:00
minetest.set_node(pos, node)
2017-03-12 02:03:45 +01:00
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.6 })
2015-06-29 19:55:56 +02:00
return true
end
end
return false
end
local hoe_longdesc = S("Hoes are essential tools for growing crops. They are used to create farmland in order to plant seeds on it. Hoes can also be used as very weak weapons in a pinch.")
local hoe_usagehelp = S("Use the hoe on a cultivatable block (by rightclicking it) to turn it into farmland. Dirt, grass blocks and grass paths are cultivatable blocks. Using a hoe on coarse dirt turns it into dirt.")
2017-03-12 01:55:18 +01:00
2017-01-31 12:35:59 +01:00
minetest.register_tool("mcl_farming:hoe_wood", {
description = S("Wood Hoe"),
2017-03-12 01:55:18 +01:00
_doc_items_longdesc = hoe_longdesc,
_doc_items_usagehelp = hoe_usagehelp,
_doc_items_hidden = false,
2015-06-29 19:55:56 +02:00
inventory_image = "farming_tool_woodhoe.png",
on_place = function(itemstack, user, pointed_thing)
2017-03-02 18:57:22 +01:00
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
end
end
if create_soil(pointed_thing.under, user:get_inventory()) then
if not minetest.settings:get_bool("creative_mode") then
2017-01-04 11:05:41 +01:00
itemstack:add_wear(65535/60)
2015-06-29 19:55:56 +02:00
end
return itemstack
end
2017-01-17 00:44:37 +01:00
end,
2019-02-25 17:46:13 +01:00
groups = { tool=1, hoe=1 },
2017-01-17 00:44:37 +01:00
tool_capabilities = {
full_punch_interval = 1,
damage_groups = { fleshy = 1, }
},
_repair_material = "group:wood",
2015-06-29 19:55:56 +02:00
})
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_wood",
2015-06-29 19:55:56 +02:00
recipe = {
2017-01-05 04:39:36 +01:00
{"group:wood", "group:wood"},
2017-01-31 23:32:56 +01:00
{"", "mcl_core:stick"},
{"", "mcl_core:stick"}
2015-06-29 19:55:56 +02:00
}
})
2017-01-10 01:59:21 +01:00
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_wood",
2017-01-10 01:59:21 +01:00
recipe = {
{"group:wood", "group:wood"},
2017-01-31 23:32:56 +01:00
{"mcl_core:stick", ""},
{"mcl_core:stick", ""}
2017-01-10 01:59:21 +01:00
}
})
2017-01-10 06:43:07 +01:00
minetest.register_craft({
type = "fuel",
2017-01-31 12:35:59 +01:00
recipe = "mcl_farming:hoe_wood",
2017-01-10 06:43:07 +01:00
burntime = 10,
})
2015-06-29 19:55:56 +02:00
2017-01-31 12:35:59 +01:00
minetest.register_tool("mcl_farming:hoe_stone", {
description = S("Stone Hoe"),
2017-03-12 01:55:18 +01:00
_doc_items_longdesc = hoe_longdesc,
_doc_items_usagehelp = hoe_usagehelp,
2015-06-29 19:55:56 +02:00
inventory_image = "farming_tool_stonehoe.png",
on_place = function(itemstack, user, pointed_thing)
2017-03-02 18:57:22 +01:00
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
end
end
if create_soil(pointed_thing.under, user:get_inventory()) then
if not minetest.settings:get_bool("creative_mode") then
2017-01-04 11:05:41 +01:00
itemstack:add_wear(65535/132)
2015-06-29 19:55:56 +02:00
end
return itemstack
end
2017-01-17 00:44:37 +01:00
end,
2019-02-25 17:46:13 +01:00
groups = { tool=1, hoe=1 },
2017-01-17 00:44:37 +01:00
tool_capabilities = {
full_punch_interval = 0.5,
damage_groups = { fleshy = 1, }
},
_repair_material = "mcl_core:cobblestone",
2015-06-29 19:55:56 +02:00
})
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_stone",
2015-06-29 19:55:56 +02:00
recipe = {
2017-01-31 23:32:56 +01:00
{"mcl_core:cobble", "mcl_core:cobble"},
{"", "mcl_core:stick"},
{"", "mcl_core:stick"}
2015-06-29 19:55:56 +02:00
}
})
2017-01-10 01:59:21 +01:00
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_stone",
2017-01-10 01:59:21 +01:00
recipe = {
2017-01-31 23:32:56 +01:00
{"mcl_core:cobble", "mcl_core:cobble"},
{"mcl_core:stick", ""},
{"mcl_core:stick", ""}
2017-01-10 01:59:21 +01:00
}
})
2015-06-29 19:55:56 +02:00
2017-02-11 21:14:40 +01:00
minetest.register_tool("mcl_farming:hoe_iron", {
description = S("Iron Hoe"),
2017-03-12 01:55:18 +01:00
_doc_items_longdesc = hoe_longdesc,
_doc_items_usagehelp = hoe_usagehelp,
2015-06-29 19:55:56 +02:00
inventory_image = "farming_tool_steelhoe.png",
on_place = function(itemstack, user, pointed_thing)
2017-03-02 18:57:22 +01:00
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
end
end
if create_soil(pointed_thing.under, user:get_inventory()) then
if not minetest.settings:get_bool("creative_mode") then
2017-01-04 11:05:41 +01:00
itemstack:add_wear(65535/251)
2015-06-29 19:55:56 +02:00
end
return itemstack
end
2017-01-17 00:44:37 +01:00
end,
2019-02-25 17:46:13 +01:00
groups = { tool=1, hoe=1 },
2017-01-17 00:44:37 +01:00
tool_capabilities = {
-- 1/3
full_punch_interval = 0.33333333,
damage_groups = { fleshy = 1, }
},
_repair_material = "mcl_core:iron_ingot",
2015-06-29 19:55:56 +02:00
})
minetest.register_craft({
2017-02-11 21:14:40 +01:00
output = "mcl_farming:hoe_iron",
2015-06-29 19:55:56 +02:00
recipe = {
2017-02-11 21:14:40 +01:00
{"mcl_core:iron_ingot", "mcl_core:iron_ingot"},
2017-01-31 23:32:56 +01:00
{"", "mcl_core:stick"},
{"", "mcl_core:stick"}
2015-06-29 19:55:56 +02:00
}
})
2017-01-10 01:59:21 +01:00
minetest.register_craft({
2017-02-11 21:14:40 +01:00
output = "mcl_farming:hoe_iron",
2017-01-10 01:59:21 +01:00
recipe = {
2017-02-11 21:14:40 +01:00
{"mcl_core:iron_ingot", "mcl_core:iron_ingot"},
2017-01-31 23:32:56 +01:00
{"mcl_core:stick", ""},
{"mcl_core:stick", ""}
2017-01-10 01:59:21 +01:00
}
})
2015-06-29 19:55:56 +02:00
2017-01-04 10:56:38 +01:00
minetest.register_craft({
type = "cooking",
2017-01-31 23:32:56 +01:00
output = "mcl_core:iron_nugget",
2017-02-11 21:14:40 +01:00
recipe = "mcl_farming:hoe_iron",
2017-01-04 11:49:05 +01:00
cooktime = 10,
2017-01-04 10:56:38 +01:00
})
2017-01-31 12:35:59 +01:00
minetest.register_tool("mcl_farming:hoe_gold", {
description = S("Golden Hoe"),
2017-03-12 01:55:18 +01:00
_doc_items_longdesc = hoe_longdesc,
_doc_items_usagehelp = hoe_usagehelp,
2015-06-29 19:55:56 +02:00
inventory_image = "farming_tool_goldhoe.png",
on_place = function(itemstack, user, pointed_thing)
2017-03-02 18:57:22 +01:00
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
end
end
if create_soil(pointed_thing.under, user:get_inventory()) then
if not minetest.settings:get_bool("creative_mode") then
2017-01-04 11:05:41 +01:00
itemstack:add_wear(65535/33)
2015-06-29 19:55:56 +02:00
end
return itemstack
end
2017-01-17 00:44:37 +01:00
end,
2019-02-25 17:46:13 +01:00
groups = { tool=1, hoe=1 },
2017-01-17 00:44:37 +01:00
tool_capabilities = {
full_punch_interval = 1,
damage_groups = { fleshy = 1, }
},
_repair_material = "mcl_core:gold_ingot",
2015-06-29 19:55:56 +02:00
})
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_gold",
2015-06-29 19:55:56 +02:00
recipe = {
2017-01-31 23:32:56 +01:00
{"mcl_core:gold_ingot", "mcl_core:gold_ingot"},
{"", "mcl_core:stick"},
{"", "mcl_core:stick"}
2015-06-29 19:55:56 +02:00
}
})
2017-01-10 01:59:21 +01:00
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_gold",
2017-01-10 01:59:21 +01:00
recipe = {
2017-01-31 23:32:56 +01:00
{"mcl_core:gold_ingot", "mcl_core:gold_ingot"},
{"mcl_core:stick", ""},
{"mcl_core:stick", ""}
2017-01-10 01:59:21 +01:00
}
})
2015-06-29 19:55:56 +02:00
2017-01-04 10:56:38 +01:00
minetest.register_craft({
type = "cooking",
2017-01-31 23:32:56 +01:00
output = "mcl_core:gold_nugget",
2017-01-31 12:35:59 +01:00
recipe = "mcl_farming:hoe_gold",
2017-01-04 11:49:05 +01:00
cooktime = 10,
2017-01-04 10:56:38 +01:00
})
2017-01-31 12:35:59 +01:00
minetest.register_tool("mcl_farming:hoe_diamond", {
description = S("Diamond Hoe"),
2017-03-12 01:55:18 +01:00
_doc_items_longdesc = hoe_longdesc,
_doc_items_usagehelp = hoe_usagehelp,
2015-06-29 19:55:56 +02:00
inventory_image = "farming_tool_diamondhoe.png",
on_place = function(itemstack, user, pointed_thing)
2017-03-02 18:57:22 +01:00
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if user and not user:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
end
end
if create_soil(pointed_thing.under, user:get_inventory()) then
if not minetest.settings:get_bool("creative_mode") then
2017-01-04 11:05:41 +01:00
itemstack:add_wear(65535/1562)
2015-06-29 19:55:56 +02:00
end
return itemstack
end
2017-01-17 00:44:37 +01:00
end,
2019-02-25 17:46:13 +01:00
groups = { tool=1, hoe=1 },
2017-01-17 00:44:37 +01:00
tool_capabilities = {
full_punch_interval = 0.25,
damage_groups = { fleshy = 1, }
},
_repair_material = "mcl_core:diamond",
2015-06-29 19:55:56 +02:00
})
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_diamond",
2015-06-29 19:55:56 +02:00
recipe = {
2017-01-31 23:32:56 +01:00
{"mcl_core:diamond", "mcl_core:diamond"},
{"", "mcl_core:stick"},
{"", "mcl_core:stick"}
2015-06-29 19:55:56 +02:00
}
})
2017-01-10 01:59:21 +01:00
minetest.register_craft({
2017-01-31 12:35:59 +01:00
output = "mcl_farming:hoe_diamond",
2017-01-10 01:59:21 +01:00
recipe = {
2017-01-31 23:32:56 +01:00
{"mcl_core:diamond", "mcl_core:diamond"},
{"mcl_core:stick", ""},
{"mcl_core:stick", ""}
2017-01-10 01:59:21 +01:00
}
})